Guest User

Untitled

a guest
Aug 10th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.47 KB | None | 0 0
  1. Lesson 2 SUMMARY
  2.  
  3.  
  4. 1. To delete from the cursor up to the next word type: dw
  5. 2. To delete from the cursor to the end of a line type: d$
  6. 3. To delete a whole line type: dd
  7.  
  8. 4. To repeat a motion prepend it with a number: 2w
  9. 5. The format for a change command is:
  10. operator [number] motion
  11. where:
  12. operator - is what to do, such as d for delete
  13. [number] - is an optional count to repeat the motion
  14. motion - moves over the text to operate on, such as w (word),
  15. $ (to the end of line), etc.
  16.  
  17. 6. To move to the start of the line use a zero: 0
  18.  
  19. 7. To undo previous actions, type: u (lowercase u)
  20. To undo all the changes on a line, type: U (capital U)
  21. To undo the undo's, type: CTRL-R
  22.  
  23.  
  24.  
  25. Lesson 3 SUMMARY
  26.  
  27.  
  28. 1. To put back text that has just been deleted, type p . This puts the
  29. deleted text AFTER the cursor (if a line was deleted it will go on the
  30. line below the cursor).
  31.  
  32. 2. To replace the character under the cursor, type r and then the
  33. character you want to have there.
  34.  
  35. 3. The change operator allows you to change from the cursor to where the
  36. motion takes you. eg. Type ce to change from the cursor to the end of
  37. the word, c$ to change to the end of a line.
  38.  
  39. 4. The format for change is:
  40.  
  41. c [number] motion
  42.  
  43.  
  44. Lesson 4 SUMMARY
  45.  
  46.  
  47. 1. CTRL-G displays your location in the file and the file status.
  48. G moves to the end of the file.
  49. number G moves to that line number.
  50. gg moves to the first line.
  51.  
  52. 2. Typing / followed by a phrase searches FORWARD for the phrase.
  53. Typing ? followed by a phrase searches BACKWARD for the phrase.
  54. After a search type n to find the next occurrence in the same direction
  55. or N to search in the opposite direction.
  56. CTRL-O takes you back to older positions, CTRL-I to newer positions.
  57.  
  58. 3. Typing % while the cursor is on a (,),[,],{, or } goes to its match.
  59.  
  60. 4. To substitute new for the first old in a line type :s/old/new
  61. To substitute new for all 'old's on a line type :s/old/new/g
  62. To substitute phrases between two line #'s type :#,#s/old/new/g
  63. To substitute all occurrences in the file type :%s/old/new/g
  64. To ask for confirmation each time add 'c' :%s/old/new/gc
  65.  
  66.  
  67. Lesson 5 SUMMARY
  68.  
  69.  
  70. 1. :!command executes an external command.
  71.  
  72. Some useful examples are:
  73. (MS-DOS) (Unix)
  74. :!dir :!ls - shows a directory listing.
  75. :!del FILENAME :!rm FILENAME - removes file FILENAME.
  76.  
  77. 2. :w FILENAME writes the current Vim file to disk with name FILENAME.
  78.  
  79. 3. v motion :w FILENAME saves the Visually selected lines in file
  80. FILENAME.
  81.  
  82. 4. :r FILENAME retrieves disk file FILENAME and puts it below the
  83. cursor position.
  84.  
  85. 5. :r !dir reads the output of the dir command and puts it below the
  86. cursor position.
  87.  
  88.  
  89. Lesson 6 SUMMARY
  90.  
  91. 1. Type o to open a line BELOW the cursor and start Insert mode.
  92. Type O to open a line ABOVE the cursor.
  93.  
  94. 2. Type a to insert text AFTER the cursor.
  95. Type A to insert text after the end of the line.
  96.  
  97. 3. The e command moves to the end of a word.
  98.  
  99. 4. The y operator yanks (copies) text, p puts (pastes) it.
  100.  
  101. 5. Typing a capital R enters Replace mode until <ESC> is pressed.
  102.  
  103. 6. Typing ":set xxx" sets the option "xxx". Some options are:
  104. 'ic' 'ignorecase' ignore upper/lower case when searching
  105. 'is' 'incsearch' show partial matches for a search phrase
  106. 'hls' 'hlsearch' highlight all matching phrases
  107. You can either use the long or the short option name.
  108.  
  109. 7. Prepend "no" to switch an option off: :set noic
  110.  
  111.  
  112. Lesson 7 SUMMARY
  113.  
  114.  
  115. 1. Type :help or press <F1> or <Help> to open a help window.
  116.  
  117. 2. Type :help cmd to find help on cmd .
  118.  
  119. 3. Type CTRL-W CTRL-W to jump to another window
  120.  
  121. 4. Type :q to close the help window
  122.  
  123. 5. Create a vimrc startup script to keep your preferred settings.
  124.  
  125. 6. When typing a : command, press CTRL-D to see possible completions.
  126. Press <TAB> to use one completion.
  127.  
  128.  
  129. Code Folding - use markers which look like "{{{1"
  130.  
  131. Movement
  132. --------
  133. w - skips to the beginning of the next word, including periods and most other chars
  134. W - skips to the next word based on whitespace
  135. b - skips to the beginning of the previous word
  136. B - skips back based on whitespace
  137. e - skips to the end of the next word
  138. E - skips to the end based on whitespace
  139. ge - skips to the end of the previous word
  140. gE - skips to the end of the previous based on whitespace
  141. $ - end of the line
  142. 0 - beginning of the line
  143. f+char - takes you to the first "char" so.. "f/" would take you to the first slash. Then ";" repeats it though I can't get that to work
  144. t+char - takes you until the char you specify so... "f/" would take you to just before the / in the direction you're going
  145. ctrl+f - page down
  146. ctrl+b - page up
  147. ctrl+u - 1/2 page down
  148. ctrl+d - 1/2 page down
  149. M - middle line
  150. H - head
  151. L - Last line on the current page
  152. * - highlights a word of the current word that you're on
  153. # - matches the full word you're on starting backwards
  154. g* - partial matches of a word going forward - can use n to go forward and N to go backwards
  155. g# - partial match of a word going backwards
  156. / and ? are regex. / goes forward, ? goes backwards
  157.  
  158. More Jumping Around
  159. -------------------
  160. [ and ] let you jump to { braces. % lets you jump between braces and quotes, etc
  161. ma - marking and jumping - you can mark a line or a char in a line then return later.
  162. :marks - shows you what marks you have in vim
  163. -> if you go to line 20 with "20G" then you can type single quote single quote '' to get back to where you were
  164. -> you can also use the backtick ` to go to the exact spot on the line you were
  165.  
  166. Editing
  167. -------
  168. i - normal drop into insert mode
  169. I - start editing at the beginning of the line
  170. a - starts inserting after the current cursor position
  171. A - starts inserting at the end of the line
  172. o - drops you down a line and puts you in insert mode
  173. O - drops you above the current line in insert mode
  174. d - deletes things
  175. dw - deletes word and space
  176. de - deletes word but leaves space
  177. dd - deletes full line
  178. 5dd - deletes 5 lines
  179. . - repeats the previous command
  180. r - single character replace
  181. R - overwrite mode
  182. c - change
  183. cw - change just the current word
  184. c3w - change 3 words to be other stuff
  185. s - substitute, similar to change - but stick with change perhaps?
  186.  
  187. :set cpoptions+=$ - this will show you the $ sign when you're changing words
  188.  
  189. Turn on virtualedit
  190.  
  191. yy - yanks a line, Y also yanks a full line
  192. p - puts the line or word
  193. shift+P - puts the line above
  194. yw - yanks just the word
  195. J - joins a line
  196. gJ - joins the line without a space
  197. v - turns on visual mode
  198. V - highlights the current line (then you can nav up and down with j,k)
  199. ctrl+v - turns on block edit mode. Then you can select stuff with the typical movement commands and then hit escape and it'll propogate to the other lines. It doesn't do it realtime like textmate
  200. gv - vertical highlighting re-highlight what was just selected
  201.  
  202.  
  203.  
  204. Buffers
  205. -------
  206. :b buffer_name - switches to that buffer, tab complete-able
  207. :bd - deletes the current buffer
  208. :bd number - deletes that number buffer
  209. :bd % - deletes all the buffers
  210. :b# - switches between two buffers
  211.  
  212. :wall - write all unsaved buffers
  213. :bufdo - allows you to iterate over the current buffers
  214. :n - next takes you to the next file
  215. :bfirst - takes you to the first buffer
  216. :bn - next buffer
  217. :bp - previous buffer
  218.  
  219. :e - will edit a file
  220.  
  221.  
  222. Windows
  223. -------
  224. ctrl + w + x - switches the two splits
  225. :vsplit or :vsp
  226. :split or :sp
  227. ctrl + w + c - closes the current split
  228. ctrl + w + o - closes the windows except for your current one (the window configuration is gone)
  229.  
  230. look at mapping ",hjkl" to move to the different splits
  231. then ctrl + w + shift + hjkl to move the split around
  232. ctrl + w + p - takes you to the previous
  233. ctrl + w + ctrl + w - cycles through splits
  234.  
  235.  
  236. VIMRC and Vim Runtime
  237. ---------------------
  238. :helptags - re-parses the files in the ~/.vim/doc directory and pulls out the tags file. Allows you to have your own documentation
  239.  
  240.  
  241. Vim Modes
  242. ---------
  243. When in visual mode you can change to select mode with "ctrl + g" then you can replace your selection
  244. ctrl + o - lets you do a single normal mode command and then it flips you back to insert
  245.  
  246.  
  247. Insert Mode
  248. -----------
  249. ctrl + d and ctrl + t - move your tab indent forward and back
  250. insert mode completion - type something and then hit "ctrl + n"
  251. ctrl + x + ctrl + l - allows you to complete complete lines
  252. ctrl + x + ctrl + f - allows you to complete files
Add Comment
Please, Sign In to add comment