Skip to content

Instantly share code, notes, and snippets.

@gdellicarpini
Last active November 3, 2017 09:59
Show Gist options
  • Save gdellicarpini/12395dd93ebdd1ec87d9a63e3e745e56 to your computer and use it in GitHub Desktop.
Save gdellicarpini/12395dd93ebdd1ec87d9a63e3e745e56 to your computer and use it in GitHub Desktop.
VI Commands
source: https://www.cs.colostate.edu/helpdocs/vi.html
u ctrl+z
MOVING CURSOR
0 (zero) move cursor to start of current line (the one with the cursor)
$ move cursor to end of current line
w move cursor to beginning of next word
b move cursor back to beginning of preceding word
:0<Return> or 1G move cursor to first line in file
:$<Return> or G move cursor to last line in file
^f move forward one screen
^b move backward one screen
^d move down (forward) one half screen
^u move up (back) one half screen
SEARCH
/string search forward for occurrence of string in text
?string search backward for occurrence of string in text
n move to next occurrence of search string
N move to next occurrence of search string in opposite direction
/copyright\c search "copyright" ignoring string case
/^string search line starting with "string"
SAVING
:w newfile<Return> write current contents to a new file named newfile
:12,35w smallfile<Return> write the contents of the lines numbered 12 through 35 to a new file named smallfile
:r filename<Return> read file named filename and insert after current line (the line with cursor)
DELETE
D delete the remainder of the line, starting with current cursor position
dd delete entire current line
COPY PASTE
Nyy or yNy copy the next N lines, including the current line, into the buffer
yy copy the current line into the buffer
p put (paste) the line(s) in the buffer into the text after the current line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment