Search This Blog


Vi Cheat Sheet

This page will just be for commands that I commonly forget for vi.
There will be many more to come as I get time (there are a ton stuck in my head)

Copy and Paste

  1. Select a line
    1. Press v to manually select a portion of the line using your cursor OR V to select the entire line
  2. Cut out the selected portion
    1. Press d to cut out the selected portion
  3. Move your cursor to where you want to paste
    1. Press p to paste the text after your cursor OR P to paste before
Find and Replace
  1. Exit out of inset mode 
    1. Press esc to exit out of insert mode
  2. Global Search and replace string
    1. Type the following
    2. :1,$ s/(match)/(replace)/g
    3. Explanation
      1.  : denotes you are going to be typing a command at the bottom of the screen
      2. 1 says begin at position 1 and $ says end at the final position on the line
      3. s denotes a string replace
      4. (match) is your matching string (replace) is the string you wish to replace
      5. /g means do this globally (for every line)

No comments:

Post a Comment