Advertisement
metalx1000

VIM key notes

Sep 3rd, 2024 (edited)
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. # increment numbers
  2. Ctrl+a+a
  3. Ctrl+x
  4.  
  5. # if you highlight multiple rows you can increment the number with
  6. g ctrl+a+a
  7. g ctrl+x
  8.  
  9. # When in visual mode and selecting lines use 'o' to switch between top and bottom
  10.  
  11. # Use '%' to jump from open and closing of chars such as () {} and []
  12. # you can also use '%' to select or delete everything in between those chars
  13.  
  14. #try this keys on the follow text
  15. diw
  16. daw
  17. di"
  18. da"
  19. di[
  20. da[
  21. di]
  22. da]
  23. di{
  24. da}
  25. di(
  26. da)
  27.  
  28. ya{
  29.  
  30. viw
  31. vaw
  32. vi"
  33. va"
  34. vi[
  35. va[
  36. vi]
  37. va]
  38. vi{
  39. va}
  40. vi(
  41. va)
  42.  
  43. #vim will jump you to the next enclosing char if you are not currently in it and
  44. #and you can jump multiple chars like so
  45. v4a{
  46. d2i{
  47. y4a{
  48.  
  49. # also use 'c' to change the selection
  50. ({["Hello World"]})
  51. (
  52. {
  53. [
  54. "Hello World"
  55. ]
  56. }
  57. )
  58.  
  59.  
  60. #select entire word no matter where in the word you are
  61. viw
  62. viW
  63.  
  64. # capital 'J' brings the next line up with spaces where newlines where
  65. # for no spaces just 'gJ'
  66.  
  67. # 'w' vs 'W' - lower case jumps to the next word while capital 'W' jumps to the next white space
  68. # try it below
  69. Phone:(555)555-1234 for John
  70.  
  71. # run a command on selection such as sort or jq
  72. :!sort
  73. :!jq .
  74. :!cut -d\, -f1,2
  75. :!sort
  76. :!sort|uniq
  77. :!figlet
  78.  
  79. # upper and lower case entire lines
  80. guu
  81. gUU
  82. # or highlight in visual and uu or UU
  83.  
  84. # if you right the name of a file on a docuemnt you can open that file by pressing
  85. gf
  86.  
  87. # reselecting text. select text in visual mode then press ESC do somethings and then press
  88. gv
  89.  
  90.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement