- A buffer in Vim is an open instance of a file, that may not necessarily be visible on the screen.
- A window in Vim is a viewport onto a single buffer. When you open a new window with :split or :vsplit and include a filename, it opens that file in a new buffer and then opens a window onto that buffer.
- A tab is a collection of one or more windows. Think of a tab as a layout for a specific group of windows. You could achieve the same thing using a terminal multiplexer like tmux, which would preserve your collection of windows and allow you to flick back and forth.
Cmd | Description |
---|---|
:ls | show buffer list |
:edit | open file in buffer to edit |
:bn, :bp | open next/prev buffer in current window |
:bfirst, :blast | open first/last buffer in current window |
:sb | split window and edit buffer by num or name |
**:bunload | unload the buffer |
- gf - edit the file under the cursor
- :e **/test/foo.js
See wildmode for tab completion with wildcards.
See also motion.txt.
- H - jump to the top of the screen
- M - jump to the middle of the screen
- L - jump to the bottom of the screen
- G - jump to the end of the file
- gg - jump to the start of the file
- '' (singlequotes) - return to line before the jump
- `` (backticks) - return to the cursor position before the jump
- zz - move current line to the middle of the screen
- zt - move current line to the top of the screen
- zb - move current line to the bottom of the screen
Cmd | Description |
---|---|
Ctrl-y | moves screen up one line |
Ctrl-e | moves screen down one line |
Ctrl-u | move screen up half a page |
Ctrl-d | moves screen down half a page |
Ctrl-b | moves screen up one page |
Ctrl-f | moves screen down one page |
- :Sex to split and open file explorer (horizontal split)
- :Sex! to split file explorer vertically
- o or O to open it in a new buffer (horizontal or vertical split)
- p to preview file (:pedit fname). use :pclose to close window.
See also Visual Mode.
Use Visual Line Mode.
- Press V (shift + v)
- Move cursor to select block of text.
- Press d
Use Ctrl+V (while in normal mode) to activate visual block mode. After selecting the block, you can press Shift+i (capital I) to start inserting before every line of the block.