Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. ## Vim Cheat Sheet
  2.  
  3. ### Navigation
  4.  
  5. - End of the file: shift + g
  6. - Next line: j
  7. - Go down a defined number of lines: number + j
  8. - Skip to next word: w
  9. - Skip back a word: b
  10. - Skip to next section: W
  11. - Skip back to previous section: B
  12. - Go to end of the line: $
  13. - Go to beginning of the line: 0
  14. - Go to top of the screen: shift + h
  15. - Go to bottom of the screen: shift + l
  16. - Forward multiple words: 5w
  17. - Forward multiple letters: 5l
  18. - Back multiple letters: 5h
  19. - Forward to the next 'y': fy (case sensitive)
  20.  
  21.  
  22. ### Editing
  23.  
  24. - Undo: u
  25. - Redo: ctrl + r
  26. - Inserting text where the cursor is: i
  27. - Inserting text at the start of the line: I
  28. - Insert at the end of the line: shift + a
  29. - Copy entire line: yy or Y
  30. - Paste copied line: p
  31. - Change multiple words: 5cw
  32. - Insert at the end of the line: A
  33.  
  34.  
  35. ### Deleting
  36.  
  37. - d<leftArrow> will delete current and left character
  38. - d$ will delete from current position to end of line
  39. - d^ will delete from current backward to first non-white-space character
  40. - d0 will delete from current backward to beginning of line
  41. - dw deletes current to end of current word (including trailing space)
  42. - db deletes current to beginning of current word
  43. - Delete current line: dd
  44. - Delete character in front: shift + j
  45. - Delete entire word: cw
  46. - Delet to the end of the line: shift + C
  47. - Delete multiple lines: d + number of lines + enter
  48. - Delete from current position to a specific line number: d<line number>G
  49. - Deleting all items in a file that start with a pattern: :g/< search term>/d
  50. - Deleting all lines that are empty or that contain only whitespace: :g/^\s*$/d
  51.  
  52.  
  53. ### Selecting
  54.  
  55. - Select the entire line: V
  56. - Select a range of text: v
  57. - Select a column: control + v
  58. - Reselect a block: gv
  59. - Select all: ggVG
  60.  
  61.  
  62. ### Find and Replace
  63.  
  64. - %s/<what to find>/<what you want to replace it with>
  65.  
  66.  
  67. ### Saving
  68.  
  69. - Save the file: :w
  70. - Save the file and quit: :wq
  71. - Quit without saving: :q!
  72.  
  73.  
  74. ### Views
  75.  
  76. - Use horizontal split: :sp filename
  77. - Use vertical split: :vsp filename
  78. - Switch from top to bottom: control + w + j
  79. - Switch from left to right: control + w + l
  80. - Switch from bottom to top: control + w + j
  81. - Switch from right to left: control + w + h
  82.  
  83.  
  84. ### Search
  85.  
  86. - While on current line: f + <queried item>
  87. - Search for word in file: /word + enter
  88. - Find next search result: n
  89. - Search backwards: N
  90. - Go to first result: ggn
  91. - Go to last result: GN
  92. - To remove search highlighting: :noh
  93.  
  94.  
  95. ### Modes
  96.  
  97. - Normal
  98. - Insert
  99. - Visual
  100. - Replace
  101. - Command Line
  102.  
  103.  
  104. ### Multiple Files
  105.  
  106. - :e filename - Edit a file in a new buffer
  107. - :bnext (or :bn) - go to next buffer
  108. - :bprev (of :bp) - go to previous buffer
  109. - :bd - delete a buffer (close a file)
  110. - :sp filename - Open a file in a new buffer and split window
  111. - ctrl + ws - Split windows
  112. - ctrl + ww - switch between windows
  113. - ctrl + wq - Quit a window
  114. - ctrl + wv - Split windows vertically
  115.  
  116.  
  117. ### Indenting
  118.  
  119. - Fix indenting when pasting: set paste in .vimrc file
  120. - Indenting: visual mode + > or <
  121. - Repeat indenting: .
  122.  
  123.  
  124. ### Visual Mode
  125.  
  126. - Changing multiple lines of text: control + v + shift + i + action + esc
  127. - Select elements in paragraph: v + / + content
  128.  
  129.  
  130. ### Display settings
  131.  
  132. - Turning on line numbers: :set nu
  133. - Turning on syntax highlighting: :syntax on
  134.  
  135.  
  136. ### Reseting Vim Settings
  137.  
  138. ```
  139. cd
  140. mv .vimrc .vimrc-old
  141. mv .vim .vim-old
  142. touch .vimrc; mkdir .vim
  143. ```
  144.  
  145. ### Help
  146.  
  147. - To get help: :h <topic>
  148. - To exit help: :bd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement