# Some Vim Movement Tips

• Within-line character-based movement:
• h and l move you left and right one character, respectively.
• f[c] or F[c] will take you forward to the next or back to the previous, respectively, occurrence of character “[c] on the current line (e.g.,fpwill jump you forward to the next occurrence of "p" on the line, whileFp will jump you back to the previous occurrence of “p” on the line).
• t[c] or T[c] will take you forward to just before the next or back to just after the previous, respectively, occurrence of character “[c] on the current line.
• ; or , repeats, forward or backward, respectively, the last f/F/t/T command.
• 0 jumps you back to the beginning of the line while \$ jumps you to the end of the line.
• ^ jumps you to the beginning of the first non-whitespace character on the current line.
• Typing in a number and then typing | takes you to a column of that number on the current line.
• Word-based movements:
• w jumps you forward to the next “beginning-of-word”, while b jumps you back to the previous “beginning-of-word” (W and B for the corresponding WORD forms).
• e jumps you forward to the next “end-of-word”, while ge jumps you back to the previous “end-of-word” (E and gE for corresponding WORD forms).
• Line-based movements:
• j and k move you down and up one line, respectively.
• + and - move you to the first non-whitespace character on the next or previous line, respectively.
• G jumps you to the last line of the buffer.
• Typing in a number and then typing G takes you to line of that number.
• gg jumps you the the first line of the buffer.
• + moves you to the first non-blank character on the previous line (same effect as k^), while - moves you the the first non-blank character on the next line (same effect as j^).
• H jumps you to the top (mnemonic=“home”) line of the current window.
• M jumps you to the middle line of the current window.
• L jumps you to the last line of the current window.
• Page-based movements:
• <C-U> moves you up half a page, while <C-D> moves you down by a half a page.
• <C-F> moves you forward a full page, while <C-B> moves you backward a full page.
• Go to a brace, bracket, parenthesis, quote, etc. Type % to jump to the matching brace, bracket, parenthesis, quote. etc.
• Search-based movements:
• With :set incsearch on, type / and starting typing in a search expression. As you type characters of the expression, you will be taken to the first location forward of the cursor position where that matching term appears in the buffer (use ? to search backwards instead of forwards). Hit <ENTER> to start working from this new position, or <ESC> to cancel and return to your original location. To find the next matching expression, hit <ENTER> and then N to iterate through all matches in the buffer. If :set wrapscan is on, then the search will wrap around the buffer. If search highlighting is turned on (:set hlsearch), all occurrences of the expression will be highlighted.
• Position the cursor over any word in an open, and (in normal mode, of course), type *. This will jump you to the next occurrence of the word under the buffer. If search highlighting is turned on (:set hlsearch), all occurrences of the word will be highlighted.
• Now type #. This time, you will be taken back to the previous occurrence of the word under the cursor.
• Typing n or N will jump to the next position in the buffer that matches the last-entered search expression (i.e., either through /, ?, *, or #).
• History-based movements:
• \.or’. will take you back to the last position or line, respectively, where you modified the file.
• \^or’^ will take you back to the last position or line, respectively, where you left insert mode.
• You can use <C-O> and <C-I> to take you backward and forward through these and other “jump” positions.
• If you are editing source code, then:
• ]m takes you forward to the next “start of a method” (i.e., the beginning of the next method).
• [m takes you back to the previous “start of a method” (i.e., the beginning of the current method if you are in the middle of one, or the beginning of the previous method if you are “in between” methods).
• This is not a movement tip per se, but it is relevant in the sense that it changes the spatial relationship of the cursor with respect to the window: zb, zt, and zz scroll the screen to make the current line at the top, bottom, or middle, respectively.