Commits

Frank Fischer committed 5a5c64a

implement buffer commands like :bn :bp

Comments (0)

Files changed (2)

vim-ex-commands.el

     (when (buffer-file-name)
       (find-file (buffer-file-name)))))
 
+(vim:defcmd vim:cmd-show-buffers (nonrepeatable)
+  "Shows the buffer-list."
+  (let (message-truncate-lines message-log-max)
+    (message "%s"
+	     (mapconcat #'buffer-name (buffer-list) "\n"))))
+
 (vim:defcmd vim:cmd-buffer ((argument:buffer buffer) nonrepeatable)
   "Switches to another buffer."
   (if buffer
         (switch-to-buffer buffer))
     (switch-to-buffer (other-buffer))))
 
+(vim:defcmd vim:cmd-next-buffer (count nonrepeatable)
+  "Goes to the `count'-th next buffer in the buffer list."
+  (dotimes (i (or count 1))
+    (next-buffer)))
+  
+(vim:defcmd vim:cmd-prev-buffer (count nonrepeatable)
+  "Goes to the `count'-th prev buffer in the buffer list."
+  (dotimes (i (or count 1))
+    (previous-buffer)))
+
+(vim:defcmd vim:cmd-split-buffer ((argument:buffer buffer) nonrepeatable)
+  "Splits window and switches to another buffer."
+  (vim:window-split)
+  (vim:cmd-buffer :argument buffer))
+
+(vim:defcmd vim:cmd-split-next-buffer (count nonrepeatable)
+  "Splits window and goes to the `count'-th next buffer in the buffer list."
+  (vim:window-split)
+  (vim:cmd-next-buffer :count count))
+  
+(vim:defcmd vim:cmd-split-prev-buffer (count nonrepeatable)
+  "Splits window and goes to the `count'-th prev buffer in the buffer list."
+  (vim:window-split)
+  ((vim:cmd-prev-buffer :count count))))
+
 (vim:defcmd vim:cmd-delete-buffer ((argument:buffer buffer) nonrepeatable)
   "Deletes a buffer."
   (kill-buffer buffer))
 (vim:emap "wa!" "wall!")
 (vim:emap "buffer" 'vim:cmd-buffer)
 (vim:emap "b" "buffer")
+(vim:emap "bnext" 'vim:cmd-next-buffer)
+(vim:emap "bn" "bnext")
+(vim:emap "bprevious" 'vim:cmd-prev-buffer)
+(vim:emap "bNext" "bprevious")
+(vim:emap "bN" "bprevious")
+(vim:emap "bp" "bprevious")
+(vim:emap "sbuffer" 'vim:cmd-split-buffer)
+(vim:emap "sb" "sbuffer")
+(vim:emap "sbnext" 'vim:cmd-split-next-buffer)
+(vim:emap "sbn" "sbnext")
+(vim:emap "sbprevious" 'vim:cmd-split-prev-buffer)
+(vim:emap "sbNext" "sbprevious")
+(vim:emap "sbN" "sbprevious")
+(vim:emap "sbp" "sbprevious")
+(vim:emap "buffers" 'vim:cmd-show-buffers)
+(vim:emap "files" "buffers")
+(vim:emap "ls" "buffers")
 
 (vim:emap "split" 'vim:window-split)
 (vim:emap "sp" "split")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.