DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

buffer-related operations in vim


Build-in Shortcuts

:enew open a new buffer in the current window (old buffers still exist);

:e open a existed file in the current window;

:sp open a file in a horizontal split window;

:vsp open a file in a vertical split window;

:new open a new buffer in a horizontal split window;

:vnew open a new buffer in a vertical split window;

:ls list all buffers available. Current buffer is marked as "%a" and last edited buffer marked as "#";

:b[N] switch to [N]th buffers, [N] is buffer number from :ls command;

:b# switch to last edited buffer;

:bn switch to next buffer(based on buffer number);

:bp switch to previous buffer(based on buffer number);

:bd close current buffer(if this is the only one buffer, a new one will be created);

:sbn/:sbp open the next/previous buffer in a horizontal split window;

:vert sbn open the next buffer in a vertical split window;

:bd[N] close buffer number [N], [N] is buffer number from :ls command;

:sb[N] open buffer [N] in a horizontal split window;

:vert sb[N] open another buffer in a vertical split window;

:vs / C-w v split window vertically;

:clo / C-w q close window;

:q quit vim no matter how many buffers exist, or close window when more than one window exist;

Read :h buffer for more.

Recommended user defined shortcuts

In .vimrc:

noremap h noremap l noremap k noremap j nnoremap q q



Published

Oct 26, 2011

Last Updated

Oct 26, 2011

Category

Tech

Tags

  • buffer 6
  • Vim 92
  • window 5

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor