Guest User

Untitled

a guest
Jul 18th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. View current file
  2. ctrl+g ; relative to vim working dir
  3. 1 ctrl+g ; full path
  4.  
  5. Word deletion
  6. daw ; delete current word
  7. caw ; delete current word/move to insert mode
  8.  
  9. Move line number to line number -/+ indicate relative line movements
  10. :-2m-4 ; move line located 2 lines above current line to 4 above current line
  11. :+2m+7 ; move line located 2 lines below current line to 7 below current line
  12.  
  13. Move a range of lines
  14. :-4,.m0 ; move range of lines 4 above current - current to the first line of file
  15.  
  16. Move a range of lines to 5 lines above current
  17. :-6,-4m+5
  18.  
  19. Delete lines relative to line number
  20. :-4,-7d ; delete lines 4 to 7 above current relative line
  21.  
  22. Same commands work with yanking. Just use 'y' instead of 'd'
  23.  
  24. ----------
  25.  
  26. dt<char> ; delete until character
  27. dT<char> ; delete backwards until character
  28.  
  29. df<char> ; delete until including character
  30. dF<char> ; delete backwards until including character
  31.  
  32. ----------
  33.  
  34. vim surround
  35.  
  36. cs"' ; changes "Hello" to 'hello'
  37. ds> ; changes <remove> to remove - deletes surrounding
  38. ds{ds) ; chain surround deletion ({ Hello } world!) - Hello world!
  39.  
  40. ysiw] ; changes word to [word]
  41. ysiw[ ; changes word to [ word ]
  42. yss) ; (wrap the entire line in brackts)
  43.  
  44. ci' -- change inside quote, for changing 'quoted' values.
  45. di' -- delete inside quote
  46. ---------
  47.  
  48. ( and ) quickly move backward and forward one sentence.
  49. { and } quickly move you up and down paragraphs.
  50.  
  51. HML will jump your cursor to high, medium, and low parts of the screen.
  52. zt, zz, and zb will similarly move your current line to the area of the screen.
  53.  
  54. I - move to beginning of line and enter insert mode
  55.  
  56. :set incsearch will set incremental search
  57. :set hlsearch will set highlight search
  58. /string will search forward for the next occurrence
  59. ?string will search backward for the previous occurrence
  60. n moved forward one match, N moves backward one match
  61. (reversed if searching .. in reverse)
  62. ggn will jump to the first match, or GN to jump to the last
  63. * searches forward for the string under the cursor
  64. # searches forward for the string under the cursor
  65. :noh will unhighlight the search
  66.  
  67. & repeats the last search-and-replace
  68.  
  69. Commenting - Nerd commenter
  70. ----------
  71. ,cs comment line
  72. ,cu uncomment line
  73.  
  74. Unit of Work
  75. ------------
  76. Changing to insert mode, making edits, and switching back to command mode is
  77. considered one unit of work in vim. The "dot operator" (.) replays the previous
  78. unit of work. This can make it to quickly repeat similar edits, like when you
  79. make an edit and then realize you have to apply the edit a few more times.
  80.  
  81. Macros
  82. ------
  83. Ever hit the wrong key and get stuck in `recording` mode? This is that.
  84. qq -- start recording
  85. q -- finish recording
  86. @q -- playback macro
  87. 10@q -- playback macro 10 times
  88.  
  89. * search forward for word under cursor; # search backward for word under cursor
  90. fx forward to next character x; Fx backward to previous character x
  91. ; move again to same character in same direction; , move again to same character in opposite direction
  92.  
  93. ------
  94. ctrl+n - scroll autocomplete
Add Comment
Please, Sign In to add comment