Skip to content

Instantly share code, notes, and snippets.

@andys8
Last active Nov 3, 2018
Embed
What would you like to do?
VIM Tutor

Vim Tutor

What I learned by vimtutor.

TL;DR

Skip this. Use vimtutor instead.

General usage

c [number] motion

Motions

  • 0 Begin of line
  • $ End of line

Undo

  • u undo
  • U undo line
  • CTRL+r redo

Jump

  • Press G to move you to the bottom of the file.
  • Jump to line 123G or :123
  • Type gg to move you to the start of the file.
  • To go back to where you came from press CTRL-O
  • CTRL-I goes forward.
  • % jumps between matching parentheses

Search

  • To search for a phrase in the backward direction, use ? instead of /.

Substitute

  • :%s/old/new/gc replace word in file with confirmation

Files

  • :w FILENAME writes the current file to disk
  • v motion :w FILENAME saves the Visually selected
  • :r FILENAME reads file and inserts it
  • :r !dir reads the output of the dir command

Insert

  • i insert
  • a insert after cursor
  • I insert begin of line
  • A insert end of line

Replace

  • r one char
  • R replace multiple chars
  • Ctrl+j remove line break

Plugins

Plug 'easymotion/vim-easymotion'

Jump in file aka Autojump ,,w

Plug 'terryma/vim-multiple-cursors'

Select next occurence of word CTRL+n

Plug 'prettier/vim-prettier', { 'do': 'npm install' }

Format code with ,p or on save

Plug 'tpope/vim-surround'

Surround with parens eg. ysiW" or ds"

Other ressources

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