Wikia

Vim Tips Wiki

Changes: Fast access to the first nine buffers

Edit

Back to page

(Method 1: mention CTRL-^ which was mentioned in the comments)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 3: Line 3:
 
|previous=966
 
|previous=966
 
|next=968
 
|next=968
|created=August 6, 2005
+
|created=2005
 
|complexity=basic
 
|complexity=basic
 
|author=Alexey Vatchenko
 
|author=Alexey Vatchenko
Line 14: Line 14:
   
 
==Method 1==
 
==Method 1==
Use <tt>Alt-''X''</tt> to quickly switch between buffers, where ''X'' is the buffer number 1 to 9.
+
Use <code>Alt-''X''</code> to quickly switch between buffers, where ''X'' is the buffer number 1 to 9.
   
 
In your .vimrc add:
 
In your .vimrc add:
Line 29: Line 29:
   
 
==Method 2==
 
==Method 2==
Use <tt><ALT><Left></tt> and <tt><ALT><Right></tt> to cycle through buffers.
+
Use <code><ALT><Left></code> and <code><ALT><Right></code> to cycle through buffers.
   
 
In your .vimrc add:
 
In your .vimrc add:
Line 38: Line 38:
 
</pre>
 
</pre>
   
==See Also==
+
==See also==
 
*{{script|id=159}} - The minibufexpl script
 
*{{script|id=159}} - The minibufexpl script
   

Latest revision as of 06:00, July 13, 2012

Tip 967 Printable Monobook Previous Next

created 2005 · complexity basic · author Alexey Vatchenko · version 6.0


When opening a number of files into buffers a user may want to switch quickly through the open buffers. The following methods will allow the user to map key combinations to buffers for easier access.

Contents

Method 1Edit

Use Alt-X to quickly switch between buffers, where X is the buffer number 1 to 9.

In your .vimrc add:

:map <M-1> :confirm :b1 <CR>
:map <M-2> :confirm :b2 <CR>
...
...
...
:map <M-9> :confirm :b9 <CR>

Note this is somewhat similar to the built-in CTRL-^ command, which can take a count to jump to a specific buffer number.

Method 2Edit

Use <ALT><Left> and <ALT><Right> to cycle through buffers.

In your .vimrc add:

" cycle through buffers with <ALT><Left> and <ALT><Right>
:nmap <M-Left> :bprev<CR>
:nmap <M-Right> :bnext<CR>

See alsoEdit

CommentsEdit

Around Wikia's network

Random Wiki