i insert at cursor position:n position the cursor on line nShift + H positions the cursor to the first character of the first lineShift + L Position the cursor to the first character of the last lineu Undoes the last editShift + U Undoes the entire line of the current cursorCtrl + r Restore the initial file statee! Undoes all changes and restores the file to the state it was in when it was openeddd Delete the current line:1,$d Delete all linesyy Copy the current linep Paste the last copy at the current cursor:/text search for text from top down, press n to search down, press N to search forward:?text Find text from bottom to top, press n to search down, press N to search forward:s/old/new Find the first occurrence of old and replace it with new:s/old/new/g Find all occurrences of old and replace them with new (current screen):%s/old/new/g Replace all olds in the entire file:%s/old/new/gc Replace all olds in the entire file, but ask if they are replaced at each occurrence:n,ms/old/new/g Replaces all olds between line numbers n and mPress ESC first and then operate the shortcut keys that follow.
:w Write but do not exit:w! Force save but don’t exit:q! Exit but not save:wq Save write and exit:w file Save the current file contents to a file:qa! Quit all files without saving, e.g., if multiple files are open:set ignorecase Ignore case lookup:set noignorecase Do not ignore case lookups:set hlsearch Highlight search results:set nohlsearch Turn off highlighting of search results:set number Show line numbers:set nonumber Don’t show line numbers