Favorite vim commands

Why vi rocks
Search and Replace in Vim

going through cursor history, works across various files. Is massively helpful when using ‘gd’ to goto definition and want to go forwards/back ctrl-i ctrl-o

ctrl-w f opens the file under your cursor in a new window. AWESOME. WORKS FOR URLS TOO (wget) gf opens file in current window (visual select if its not working) ctrl-w gf opens in new tab

ge goes back using ends of words

‘%’ finds end of parenthases ‘*’ searches for word under cursor

ctrl-x ctrl-f for finding a file (completion)

insert mode: ctrl-r then register to input the contents of a register ctrl-a or ctrl-r . to repeat the previous inserted text

ctrl-x ctrl-l for whole line completion ctrl-x ctrl-n for word completion ctrl-x puts vim in completion mode, then specifiy what type of completion after (ex: ctrl-] for a tags completion) ctrl-x ctrl-o for language aware completion

:e to edit a file

:set spell to enable spell checking

Indent 7 lines (alternative to visual block)

> 7 j

View Movement

Control-b - Move back one full screen Control-f - Move forward one full screen Control-d - Move forward ½ screen Control-u - Move back (up) ½ screen

quickfix lists

:vimgrep search_term **/*.txt text files

:copen view the quickfix list

when over a word that you want to search, press * to search for it

how to use telescope.vim

how to save macros copy from register into vimrc as remap

Commands

:find : find and open file

:r![shell command] read outout of command into buffer

:r reads file contents into current buffer

You can * in a word, and then :%s//replacement will replace that word for replacement

:Ex to bring up built in file viewer

:bn to go to next buffer, :ls ot list buffers

Other

q: brings up buffer of command history (for resuing)

visual mode : use :norm on selection and will run that normal mode command on the selection (alternative to visual block stuff)

Registers

Registers “rp paste from r register "ry yank into r register Ctrl-r r for when in insert mode :reg to view registers ”: register has most recent command ctrl-r {register} while typing in command will enter that register into commnad (good for search and replace)