a place for cheatsheets i make or possibly steal
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

vimcheat.html 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <html>
  2. <head>
  3. <title>vim cheatsheet</title>
  4. <style>
  5. body {
  6. font-family: Georgia, Serif;
  7. margin-left: 2em;
  8. }
  9. th {
  10. font-size: normal;
  11. text-align: right;
  12. }
  13. td {
  14. padding-right: .5em;
  15. padding-left: .5em;
  16. padding-bottom: .5em;
  17. vertical-align: top;
  18. }
  19. td.keymap {
  20. text-align: center;
  21. }
  22. kbd {
  23. /* border-bottom: 1px solid #EAEEF2;
  24. border-right: 1px solid #EAEEF2; */
  25. padding: 1px;
  26. }
  27. kbd, pre, td.keymap {
  28. font-family: monospace;
  29. font-weight: bold;
  30. font-size: larger;
  31. color: green;
  32. }
  33. .change kbd, kbd.change { color: orange; }
  34. .insert kbd, kbd.insert { color: blue; }
  35. .delete kbd, kbd.delete { color: red; }
  36. i { color: gray; }
  37. </style>
  38. </head>
  39. <body>
  40. <table>
  41. <tr>
  42. <th>edit</th>
  43. <td>
  44. <span class="insert">
  45. <kbd>i</kbd>nsert at cursor<br>
  46. <kbd>I</kbd>nsert at start<br>
  47. <kbd>a</kbd>ppend after cursor<br>
  48. <kbd>A</kbd>ppend to line<br>
  49. </span>
  50. </td>
  51. <td>
  52. <span class="delete">
  53. <kbd>x</kbd> kill char<br>
  54. <kbd>X</kbd> kill back<br>
  55. <kbd>d</kbd>elete/cut text<br>
  56. <kbd>d<i>obj</i></kbd> - <kbd>dw</kbd>, <kbd>d$</kbd>, etc.<br>
  57. <kbd>dd</kbd> clears whole line<br>
  58. <kbd>D</kbd> to end of line
  59. </span><br>
  60. <span class="change"><kbd>c</kbd>hange - <kbd>c<i>obj</i></kbd>, <kbd>ci<i>obj</i></kbd>, <kbd>cc</kbd>, <kbd>C</kbd></span><br>
  61. </td>
  62. <td>
  63. <kbd class="change">r</kbd>eplace one char<br>
  64. <kbd class="change">R</kbd>eplace text<br>
  65. <span class="change"><kbd>s</kbd>ubstitute char</span><br>
  66. <kbd>y</kbd>ank/copy - <kbd>y<i>obj</i></kbd>, <kbd>yy</kbd><br>
  67. <kbd>p</kbd>ut (paste)<br>
  68. <kbd>u</kbd>ndo, <kbd>ctrl-r</kbd>edo<br>
  69. <kbd>v</kbd>isual select<br>
  70. <kbd>.</kbd> repeat edit
  71. </td>
  72. </tr>
  73. <tr>
  74. <th>move</th>
  75. <td>
  76. <kbd>e</kbd>nd, <kbd>b</kbd>egin <kbd>w</kbd>ord<br>
  77. <kbd>$</kbd>,<kbd>0</kbd> end, begin line<br>
  78. <kbd>(</kbd>,<kbd>)</kbd> sentence &larr;, &rarr;<br>
  79. <kbd>{</kbd>,<kbd>}</kbd> paragraph &larr;, &rarr;<br>
  80. <kbd>ctrl-b</kbd>ack, <kbd>ctrl-f</kbd>wd page<br>
  81. <kbd>fA</kbd> goes to next "A"<br>
  82. <kbd>tA</kbd> before next "A"
  83. </td>
  84. <td class="keymap">
  85. <small>gg</small><br>
  86. <small>&lt;C-b&gt;</small><br>
  87. H<br>
  88. k<br>
  89. { ( B b h l w W ) }<br>
  90. j<br>
  91. L<br>
  92. <small>&lt;C-f&gt;</small><br>
  93. <small>G</small>
  94. </td>
  95. <td>
  96. <kbd>/<i>pattern</i></kbd> &rarr;<br>
  97. <kbd>?<i>pattern</i></kbd> &larr;<br>
  98. <kbd>n</kbd>ext <i>pattern</i><br>
  99. <kbd>*</kbd> word under cursor<br>
  100. <kbd>%</kbd> matching bracket<br>
  101. <kbd>m<i>x</i></kbd> set mark <i>x</i><br>
  102. <kbd>``</kbd> go back, <kbd>`<i>x</i></kbd> to mark
  103. </td>
  104. </tr>
  105. <tr>
  106. <th>files<br><small>&amp; windows</small></th>
  107. <td>
  108. <kbd>:e <i>file</i></kbd> edit<br>
  109. <kbd>:w <i>file</i></kbd> write<br>
  110. <kbd>:wq</kbd> write &amp; quit<br>
  111. <kbd>:r <i>file</i></kbd> read into buffer<br>
  112. <kbd>:r !<i>command</i></kbd> - get output<br>
  113. <kbd>:sp <i>file</i></kbd> - in new window<br>
  114. <kbd>:q</kbd> - quit buffer/window
  115. </td>
  116. <td colspan=2><kbd>ctrl-w</kbd> then...<br>
  117. <kbd>n</kbd>ew<br>
  118. <kbd>s</kbd>plit current<br>
  119. <kbd>v</kbd>ertical split<br>
  120. <kbd>h</kbd>, <kbd>j</kbd>, <kbd>k</kbd>, <kbd>l</kbd> jump &larr; &darr; &uarr; &rarr;<br>
  121. <kbd>+</kbd>, <kbd>-</kbd>, <kbd>=</kbd> size current<br>
  122. <kbd>f</kbd>ile under cursor in new window<br>
  123. </td>
  124. </tr>
  125. </table>
  126. <p>- - - cut or fold here - - -</p>
  127. <table>
  128. <tr>
  129. <th>style</th>
  130. <td>
  131. <kbd>:set expandtab</kbd> - use spaces<br>
  132. <kbd>:set shiftwidth=2</kbd><br>
  133. <kbd>:set textwidth=70</kbd><br>
  134. <kbd>:set nowrap</kbd>
  135. </td>
  136. <th>tweak</th>
  137. <td>
  138. <kbd class="change">J</kbd>oin<br>
  139. <kbd class="change">gq<i>obj</i></kbd> - autoformat<br>
  140. <kbd>~</kbd> change case of char<br>
  141. <kbd>&gt;&gt;</kbd>,<kbd>&lt;&lt;</kbd> indent, unindent<br>
  142. <kbd>=</kbd> autoindent<br>
  143. <kbd>:rangesort</kbd><br>
  144. </td>
  145. </tr>
  146. </table>
  147. <p><kbd><i>n</i>ctrl-a</kbd>, <kbd><i>n</i>ctrl-x</kbd> - inc or dec number by <i>n</i></p>
  148. <p><kbd class="change">:s/pattern/replacement/g</kbd> - on this line (g for multiple)<br>
  149. <kbd class="change">:%s/pattern/replacement/gc</kbd> - on every line but confirm<br>
  150. <kbd class="change">:perldo s/foo/bar/g</kbd> - do Perl on every line<br>
  151. <kbd class="change">:.perldo s/bar/baz/g</kbd> - do Perl on this line</p>
  152. </body>
  153. </html>