Skip to content

arthurian/vimcheatsheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

vimcheatsheet

Editing

Buffers, Windows, Tabs

  1. A buffer in Vim is an open instance of a file, that may not necessarily be visible on the screen.
  2. 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.
  3. 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.

Buffers

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

Edit file under cursor

  • gf - edit the file under the cursor

Find file recursively to edit

  • :e **/test/foo.js

See wildmode for tab completion with wildcards.

Movement

See also motion.txt.

Jumping around the screen

  • 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

Scrolling the screen

  • 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

File Explorer

  • :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.

Visual Mode

See also Visual Mode.

Visual Line Mode: Remove block of text

Use Visual Line Mode.

  1. Press V (shift + v)
  2. Move cursor to select block of text.
  3. Press d

Visual Block Mode: Insert text

Use Blockwise Visual Mode.

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.

About

VIM cheat sheet

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published