VIM CHEAT SHEET - VimCommandsCheatSheet HowtoExit :q[uit]...

This preview shows page 1 - 4 out of 7 pages.

The preview shows page 2 - 4 out of 7 pages.
Vim Commands Cheat SheetHow to Exit:q[uit]Quit Vim. This fails when changes have been made.:q[uit]!Quit without writing.:cq[uit]Quit always, without writing.:wqWrite the current file and exit.:wq!Write the current file and exit always.:wq {file}Write to {file}. Exit if not editing the last:wq! {file}Write to {file} and exit always.:[range]wq[!][file] Same as above, but only write the lines in [range].ZZWrite current file, if modified, and exit.ZQQuit current file and exit (same as ":q!").Editing a File:e[dit]Edit the current file. This is useful to re­edit the current file, when it has been changed outside ofVim.:e[dit]!Edit the current file always. Discard any changes to the current buffer. This is useful if you want tostart all over again.:e[dit]{file}Edit {file}.:e[dit]!{file}Edit {file} always. Discard any changes to the current buffer.gfEdit the file whose name is under or after the cursor. Mnemonic: "goto file".Inserting TextaAppend text after the cursor [count] times.AAppend text at the end of the line [count] times.iInsert text before the cursor [count] times.IInsert text before the first non­blank in the line [count] times.gIInsert text in column 1 [count] times.oBegin a new line below the cursor and insert text, repeat [count] times.OBegin a new line above the cursor and insert text, repeat [count] times.
Inserting a file:r[ead] [name]Insert the file [name] below the cursor.:r[ead] !{cmd}Execute {cmd} and insert its standard output below the cursor.Deleting Text<Del> orxDelete [count] characters under and after the cursorXDelete [count] characters before the cursord{motion}Delete text that {motion} moves overddDelete [count] linesDDelete the characters under the cursor until the end of the line{Visual}x or{Visual}dDelete the highlighted text (for {Visual} seeSelecting Text).{Visual}CTRL­H or{Visual}When in Select mode: Delete the highlighted text{Visual}X or{Visual}DDelete the highlighted lines:[range]d[elete]Delete [range] lines (default: current line):[range]d[elete] {count}Delete {count} lines, starting with [range]Changing (or Replacing) Textr{char}replace the character under the cursor with {char}.REnter Insert mode, replacing characters rather than inserting~Switch case of the character under the cursor and move the cursor to the right. If a [count] is given,do that many characters.~{motion}switch case of {motion} text.{Visual}~ Switch case of highlighted textSubstituting:[range]s[ubstitute]/{pattern}/{string}/[c][e][g][p][r][i][I] [count]For each line in [range] replace a match of {pattern} with {string}.:[range]s[ubstitute] [c][e][g][r][i][I][count] :[range]&[c][e][g][r][i][I] [count]Repeat last :substitute with same search pattern and substitutestring, but without the same flags. You may add extra flags
The arguments that you can use for the substitute commands:[c]Confirm each substitution.

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 7 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Winter
Professor
N/A
Tags

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture