Skip to content

Instantly share code, notes, and snippets.

@shanev
Last active September 5, 2021 16:30
Show Gist options
  • Save shanev/4d03b174a5c3f107b434c909bfa0d0e4 to your computer and use it in GitHub Desktop.
Save shanev/4d03b174a5c3f107b434c909bfa0d0e4 to your computer and use it in GitHub Desktop.
vim8 Cheat Sheet

VIM CHEAT SHEET

Navigation

Quit all :qa

Go to top of file :gg

Go to bottom of file Shift-g

Go back Ctrl-o

Go back to previous file Ctrl-^

Move to next word w

Move up/down half screen Ctrl-u Ctrl-d

Move to next function ]]

Move to prev function [[

Goto line [line#] Shift-g

Move to beginning of line 0

Move to end of line $

Editor

Explorer :Ex

Terminal :term (vim8 only)

Close quickfix list :ccl

Close scratch preview :pc

Split screen Ctrl-w v

Go to right screen Ctrl-w l

Go to left screen Ctrl-w h

Text

Undo u

Delete line dd

Search/replace in file :%s/search/replace/g

Find word under cursor *

Comments

Line

\\ (mapped to gcc via Commentry plugin)

Block

  1. Ctrl-v to enter visual block mode

  2. select lines with , or if for inner function

  3. Shift-i for insert mode

  4. // (or other comment symbol)

  5. ESC

Copy/paste

Select a line V (enters visual selection mode)

Cut d

Copy y (yank)

Paste p

Sessions

Save session :mks (or :mks! if already exists)

Load session vim -S Session.vim or :source Session.vim

Plugins

vim-go

Goto def gd

Show godoc K

Run tests F10

Show coverage F9

Toggle test \ga, \gah horizontal, \gav vertical split

NERDTree

Toggle \p (mapped to :NERDTreeToggle)

Open verticle split s

Open horizontal split i

Airline

:AirlineTheme <theme>

Fugitive

Git commands :Git [command], i.e: :Git blame, :Git status

Language Servers (neovim)

:LspInfo

Rust.vim

Format code :RustFmt

Run test under cursor :RustTest

@shanev
Copy link
Author

shanev commented Aug 25, 2021

@shanev
Copy link
Author

shanev commented Sep 5, 2021

Git rebase WIP:

Place the cursor at the beginning of the line with the first commit you want to fixup
Enter visual block mode (CTRL-V)
Select all the rows you want to fixup
Hit 'c' and type 'f' to replace the 'pick' command
Press ESC to apply that change to all the selected rows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment