CoyoteCrafty

Vim Shortcuts

Oct 23rd, 2018
6,712
0
Never
3
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 2.86 KB | None | 0 0
  1. Cursor movement
  2. h       move left
  3. j       move down
  4. k       move up
  5. l       move right
  6. w       jump by start of words (punctuation considered words)
  7. W       jump by words (spaces separate words)
  8. e       jump to end of words (punctuation considered words)
  9. E       jump to end of words (no punctuation)
  10. b       jump backward by words (punctuation considered words)
  11. B       jump backward by words (no punctuation)
  12. 0       (zero) start of line
  13. ^       first non-blank character of line
  14. $       end of line
  15. G       Go To command (prefix with number
  16.         Note:   Prefix a cursor movement command with a number to repeat it. For example, 4j moves down 4 lines.
  17.  
  18. Insert Mode Inserting/Appending text
  19. i       start insert mode at cursor
  20. I       insert at the beginning of the line
  21. a       append after the cursor
  22. A       append at the end of the line
  23. o       open (append) blank line below current line (no need to press return)
  24. O       open blank line above current line
  25. ea      append at end of word
  26. Esc     exit insert mode
  27.  
  28. Editing
  29. r       replace a single character (does not use insert mode)
  30. J       join line below to the current one
  31. cc      change (replace) an entire line
  32. cw      change (replace) to the end of word
  33. c$      change (replace) to the end of line
  34. s       delete character at cursor and subsitute text
  35. S       delete line at cursor and substitute text (same as cc)
  36. xp      transpose two letters (delete and paste, technically)
  37. u       undo
  38. .       repeat last command
  39. Marking text (visual mode)
  40. v       start visual mode, mark lines, then do command (such as y-yank)
  41. V       start Linewise visual mode
  42. o       move to other end of marked area
  43. Ctrl+v  start visual block mode
  44. O       move to Other corner of block
  45. aw      mark a word
  46. ab      a () block (with braces)
  47. aB      a {} block (with brackets)
  48. ib      inner () block
  49. iB      inner {} block
  50. Esc     exit visual mode
  51.  
  52. Visual commands
  53. >       shift right
  54. <       shift left
  55. y       yank (copy) marked text
  56. d       delete marked text
  57. ~       switch case
  58.  
  59. Cut and Paste
  60. yy      yank (copy) a line
  61. 2yy     yank 2 lines
  62. yw      yank word
  63. y$      yank to end of line
  64. p       put (paste) the clipboard after cursor
  65. P       put (paste) before cursor
  66. dd      delete (cut) a line
  67. dw      delete (cut) the current word
  68. x       delete (cut) current character
  69.  
  70. Exiting
  71. :w      write (save) the file, but don't exit
  72. :wq     write (save) and quit
  73. :q      quit (fails if anything has changed)
  74. :q!     quit and throw away changes
  75.  
  76. Search/Replace
  77. /pattern    search for pattern
  78. ?pattern    search backward for pattern
  79. n       repeat search in same direction
  80. N       repeat search in opposite direction
  81. :%s/old/new/g   replace all old with new throughout file
  82. :%s/old/new/gc  replace all old with new throughout file with confirmations
  83.  
  84. Working with multiple files
  85. :e filename Edit a file in a new buffer
  86. :bnext      go to next buffer
  87. (or :bn)
  88. :bprev      go to previous buffer
  89. (of :bp)
  90. :bd         delete a buffer (close a file)
  91. :sp filename    Open a file in a new buffer and split window
  92. ctrl+ws     Split windows
  93. ctrl+ww     switch between windows
  94. ctrl+wq     Quit a window
  95. ctrl+wv     Split windows vertically
Advertisement