sponsor Vim development Vim logo Vim Book Ad

basic Tip #401: A mapping for easy switching between buffers

 tip karma   Rating 24/10, Viewed by 1662 

Read and edit this tip on the Vim tip wiki. The wiki may have a more recent version of this tip.

created:   January 14, 2003 3:27      complexity:   basic
author:   chris      as of Vim:   6.0

Instead of using a buffer-explorer I looked for a simpler method for fast switching between buffers. So on a rainy day I invented a simple mapping:

map  <C-Up> :bn<Return>
map  <C-Down> :bp<Return>

This works very well for an intermediate amount of buffers. Of course you can take other keys (instead of the up and down arrows) for the mapping.


 rate this tip  Life Changing Helpful Unfulfilling 

<< Fast scroll mappings (incl. insert mode) | Just using space-bar: jump between splitted windows and open them wide >>

Additional Notes

yourock@devo.com, January 14, 2003 18:53
Shazam!  That _vimrc is gettin way too big.
tom, September 28, 2004 18:26
This is exactly what I use and I love it too.  One thing I would note is that you can't switch from a dirty (edited) bufffer unless you also do this:

set hidden

Probably in your .vimrc file.  That way you can switch between buffers without each one having to be saved.  
inetic, April 29, 2005 14:01
i use:

nmap <C-j> :bnext<CR>:redraw<CR>:ls<CR>
nmap <C-k> :bprevious<CR>:redraw<CR>:ls<CR>

thus you can see your files while browsing.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
SourceForge.net Logo