Complete Vim Reference Guide

Created: 9/13/2019 Updated: 9/14/2019

Vim Basics: Navigation
                            h or j or k or l "Move left/down/up/right"
                        

Closer to your fingers than arrow keys.

                             G or ]]     "Jump to the last line"
                        
                             gg or [[   "Jump to the first line"
                        

G and gg are useful for navigating throughout a file. Esepcially useful for looking at headers or adding new functions

                             $   "Jump to the end of the line"
                        
                             0   "Jump to the beginning of the line"
                        
                             ^   "Jump to the first non-blank character in the line"
                        

These commands are useful in navigating within lines. '$' can allow you to make edits to the end of the line and '0' can allow you to make edits to the beginning. '^' is useful when there is lot of identation. Personally, I find a lot more use using '^' than '0'.

                            w or CTRL-RIGHT "Move forward one word"
                        
                            b or CTRL-LEFT "Move back one word"
                        

Another pair of commands that let you navigate within a line. Its more fine grain than moving to the beginning or end of the line.

                           H "Jump to the top of the screen"
                        
                            M "Jump to the middle of the screen"
                        
                            L "Jump to the bottom of the screen"
                        

These commands are useful when navigating within a screen. They stand for (H)igh, (M)iddle, and (L)ow. These commands will not cause the screen to scroll. It will only move the cursor to a location on the currently viewable screen

                            CTRL-Y "Scroll up one line"
                        
                            CTRL-E "Scroll down one line"
                        

This pair of commands do not move the cursor. It only moves the screen up or down. Its pretty useful to see the context of the code that you are looking at.

                            CTRL-U "Scroll up half the screen"
                        
                            CTRL-D "Scroll down half the screen" 
                        

These commands allow you to navigate throughout the file. I use these commands a lot when looking throughout the file.

                            CTRL-o "Jump to the previous cursor location"
                        
                            CTRL-i "Jump to the next cursor location"
                        

These commands allow you to jump to lines that you were looking at earlier.

                            { or } "Jump to the previous/next blank line existing"
                        

It allows you to skip chunks of code. Pretty useful.

                            /pattern "Search for pattern forward"
                        
                            ?pattern "Search for pattern backward"
                        
                            n or N "Jump to the next/previous pattern found"
                        

Searching for some regex pattern. Extremely useful! Lowercase n jumps to the next occurance. Uppercase N jumps to the previous occurance.

Vim Basics: Editing
                           i "Insert text at current cursor position"
                        
                            I "Insert text at the beginning of the line"
                        
                            A "Append text at end of line"
                        
                            S "Remove the line and enter insert mode"
                        
                            C "Remove the text from the cursor position to the end of the line"
                        

All of these commands will cause you to enter insert mode. Getting an understanding of when to use each command allows you to become a lot more efficient in programming

                            O "Open a new line above the current line"
                        
                            o "Open a new line below the current line"
                        

Both of these commands will cause you to enter insert mode.

                            u "Undo the last action"
                        
                            CTRL-R "Redo the last action"
                        

Undo and Redo commands

                           . "Repeat action just performed"
                        
                            dd "Deletes the current line (Also copies to clipboard)"
                        
                            yy "Copy the whole current line"
                        

These commands can all be prepended with a number. For example "7." will repeat the last action 7 times. "7dd" will delete 7 lines. "7yy" will copy the next 7 lines (including the current line).

                            P "Paste the line above the current line"
                        
                            p "Paste the line below the current line"
                        

Classic paste command

                            r "Enable to replace one character"
                        
                            s "Remove the character and enter insert mode"
                        

'r' allows you to replace a single character without going into insert mode. 's' will remove a character and enter insert mode.

                            * "Search for word below the cursor"
                        

Does a search for whatever word the cursor is on. Very useful

                            [l "List the lines including the word below the cursor"
                        

Shows you a list of occurances of that word that include line numbers

                           V "Select the whole line"
                        
                            v "Select a portion of the current line"
                        
                            CTRL-v "Select a text portion of multiple lines"
                        
                            gv "Reselect the last selection made"
                        

These commands deal with selections, which then can be manipulated. The UP, DOWN, RIGHT, and LEFT Keys can be used to change the selection. "CTRL-v" is useful for cropping multiple lines

                            ~ "Change the case of selected character"
                        

Self explanatory

                            << or >> "Indent left or right"
                        

Lets you indent lines. Press '.' to continue to indent in the same direction

                            vip "Selects entire paragrah"
                        

Can join the lines by pressing 'J' afterwards.