HomeBooksDigital GardenStoreContact

Vim Commands

These are notes on vim from Lesson 3 of Missing Semester, this lesson contains a lot of useful information about Vim.

Since I've written a quick introduction to vim, the notes on this post are just something to complement that article. I will probably update that article with these notes in the future.

The one thing that I loved learning in this lesson was how to create new windows and tabs. The lesson didn't mention how to cycle through them, so I did a quick search to figure out how to do it.

Normal mode:

  • click X to remove a letter
  • use :qa to close all windows

Vim windows can have tabs.

  • use :sp to create a new windows
    • Cycle between tabs with ctrl+w
  • use :tabnew to open a new tab that can contain a window or more
    • Move between tabs with ctrl+PgUp or ctrl+PgDn

Moving around

  • use e to move to the end of the word
  • 0 moves the cursor to the beginning of the line
  • $ moves the cursor to the end of the line
  • ^ moves to the first non-empty character of a line
  • ctrl+u scrolls up
  • ctrl+d scrolls down
  • G moves to the end of the file
    • so does :$
  • gg moves to the beginning of the file
  • L moves to the lowest line in the screen
  • M moves to the middle line in the screen
  • H moves to the highest line in the screen
  • f<character> moves the cursor to the first character - f stands for find
  • t<character> move cursor to character
  • /<word> search word

Editing commands

  • u undo changes
  • ctrl+r redo changes
  • o opens a new line under the cursor
  • O opens a new line on top of the cursor
  • c change mode - used similarly to d but puts you in insert mode
    • ci' change word inside '
  • x delete a character
  • r replace character
  • y copy
    • yy copy the whole line
    • pw copy word
  • p paste
  • ~ change the case of the selected text
  • a append word
  • . repeat the previous command