Advertisement
metalx1000

VIM Notes

Mar 17th, 2017
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 1.43 KB | None | 0 0
  1. #VIM Notes
  2. #run a command and put the output into the current file
  3. :r !ifconfig
  4.  
  5. #run a command against the current file
  6. :%!grep netmask
  7.  
  8. #but since VIM has built in tools you don't need grep
  9. #search for all matches
  10. :g/netmask/
  11.  
  12. #jump to line number 42
  13. 42G
  14.  
  15. #delete all lines that don't match
  16. :v/netmask/d
  17.  
  18. #substitution
  19. :%s/^.*inet /
  20. #delete everything before "inet " on a line
  21. :%s/^.*inet /
  22. #delete everything after "  net" on a line
  23. :%s/  net.*/
  24.  
  25. #use grep to get ip addresses from a file
  26. :%!grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"
  27.  
  28. #history search
  29. q:/
  30.  
  31. #move to bottom of screen
  32. L
  33.  
  34. #center screen on current line
  35. zz
  36.  
  37. #center current line at top of the screen
  38. zt
  39. #at bottom
  40. zb
  41.  
  42. #up and down page
  43. Ctrl+u
  44. Ctrl+b
  45.  
  46. #moving to beginning or end of line
  47. 0
  48. $
  49. ^
  50. g_
  51.  
  52. #record a macro
  53.  
  54. qd  start recording to register d
  55. ... your complex series of commands
  56. q   stop recording
  57. @execute your macro
  58. @@  execute your macro again
  59.  
  60. #find next and previous instance of the current word you are on
  61. *
  62. #
  63.  
  64. #jump by work
  65. w
  66. e
  67.  
  68. #delete everything up to or including a charactor
  69. #quotes in this example
  70. dt"
  71. df"
  72.  
  73. #change/delete inner tag html
  74. cit
  75. dit
  76.  
  77. #change/delete between quotes
  78. ci"
  79. di"
  80.  
  81. #find opening/closing of functions
  82. %
  83.  
  84. #spell check
  85. :set spell spelllang=en_us
  86. :set nospell
  87. z=
  88.  
  89. #mark a spot and return to it
  90. mm
  91. 'm
  92.  
  93. #increment a number
  94. ctrl-a
  95.  
  96. #go back in time 2 minutes
  97. earlier 2m
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement