Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.88 KB | None | 0 0
  1. Lesson 1 SUMMARY
  2.  
  3.  
  4. 1. The cursor is moved using either the arrow keys or the hjkl keys.
  5. h (left) j (down) k (up) l (right)
  6.  
  7. 2. To start Vim from the shell prompt type: vim FILENAME <ENTER>
  8.  
  9. 3. To exit Vim type: <ESC> :q! <ENTER> to trash all changes.
  10. OR type: <ESC> :wq <ENTER> to save the changes.
  11.  
  12. 4. To delete the character at the cursor type: x
  13.  
  14. 5. To insert or append text type:
  15. i type inserted text <ESC> insert before the cursor
  16. A type appended text <ESC> append after the line
  17.  
  18. NOTE: Pressing <ESC> will place you in Normal mode or will cancel
  19. an unwanted and partially completed command.
  20.  
  21. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  22. Lesson 2 SUMMARY
  23.  
  24.  
  25. 1. To delete from the cursor up to the next word type: dw
  26. 2. To delete from the cursor to the end of a line type: d$
  27. 3. To delete a whole line type: dd
  28.  
  29. 4. To repeat a motion prepend it with a number: 2w
  30. 5. The format for a change command is:
  31. operator [number] motion
  32. where:
  33. operator - is what to do, such as d for delete
  34. [number] - is an optional count to repeat the motion
  35. motion - moves over the text to operate on, such as w (word),
  36. $ (to the end of line), etc.
  37.  
  38. 6. To move to the start of the line use a zero: 0
  39.  
  40. 7. To undo previous actions, type: u (lowercase u)
  41. To undo all the changes on a line, type: U (capital U)
  42. To undo the undo's, type: CTRL-R
  43.  
  44. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  45. Lesson 3 SUMMARY
  46.  
  47.  
  48. 1. To put back text that has just been deleted, type p . This puts the
  49. deleted text AFTER the cursor (if a line was deleted it will go on the
  50. line below the cursor).
  51.  
  52. 2. To replace the character under the cursor, type r and then the
  53. character you want to have there.
  54.  
  55. 3. The change operator allows you to change from the cursor to where the
  56. motion takes you. eg. Type ce to change from the cursor to the end of
  57. the word, c$ to change to the end of a line.
  58.  
  59. 4. The format for change is:
  60.  
  61. c [number] motion
  62.  
  63. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  64. Lesson 4 SUMMARY
  65.  
  66.  
  67. 1. CTRL-G displays your location in the file and the file status.
  68. G moves to the end of the file.
  69. number G moves to that line number.
  70. gg moves to the first line.
  71.  
  72. 2. Typing / followed by a phrase searches FORWARD for the phrase.
  73. Typing ? followed by a phrase searches BACKWARD for the phrase.
  74. After a search type n to find the next occurrence in the same direction
  75. or N to search in the opposite direction.
  76. CTRL-O takes you back to older positions, CTRL-I to newer positions.
  77.  
  78. 3. Typing % while the cursor is on a (,),[,],{, or } goes to its match.
  79.  
  80. 4. To substitute new for the first old in a line type :s/old/new
  81. To substitute new for all 'old's on a line type :s/old/new/g
  82. To substitute phrases between two line #'s type :#,#s/old/new/g
  83. To substitute all occurrences in the file type :%s/old/new/g
  84. To ask for confirmation each time add 'c' :%s/old/new/gc
  85.  
  86. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  87. Lesson 5 SUMMARY
  88.  
  89.  
  90. 1. :!command executes an external command.
  91.  
  92. Some useful examples are:
  93. (MS-DOS) (Unix)
  94. :!dir :!ls - shows a directory listing.
  95. :!del FILENAME :!rm FILENAME - removes file FILENAME.
  96.  
  97. 2. :w FILENAME writes the current Vim file to disk with name FILENAME.
  98.  
  99. 3. v motion :w FILENAME saves the Visually selected lines in file
  100. FILENAME.
  101.  
  102. 4. :r FILENAME retrieves disk file FILENAME and puts it below the
  103. cursor position.
  104.  
  105. 5. :r !dir reads the output of the dir command and puts it below the
  106. cursor position.
  107.  
  108.  
  109. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  110. Lesson 6 SUMMARY
  111.  
  112. 1. Type o to open a line BELOW the cursor and start Insert mode.
  113. Type O to open a line ABOVE the cursor.
  114.  
  115. 2. Type a to insert text AFTER the cursor.
  116. Type A to insert text after the end of the line.
  117.  
  118. 3. The e command moves to the end of a word.
  119.  
  120. 4. The y operator yanks (copies) text, p puts (pastes) it.
  121.  
  122. 5. Typing a capital R enters Replace mode until <ESC> is pressed.
  123.  
  124. 6. Typing ":set xxx" sets the option "xxx". Some options are:
  125. 'ic' 'ignorecase' ignore upper/lower case when searching
  126. 'is' 'incsearch' show partial matches for a search phrase
  127. 'hls' 'hlsearch' highlight all matching phrases
  128. You can either use the long or the short option name.
  129.  
  130. 7. Prepend "no" to switch an option off: :set noic
  131.  
  132. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  133. Lesson 7 SUMMARY
  134.  
  135.  
  136. 1. Type :help or press <F1> or <Help> to open a help window.
  137.  
  138. 2. Type :help cmd to find help on cmd .
  139.  
  140. 3. Type CTRL-W CTRL-W to jump to another window
  141.  
  142. 4. Type :q to close the help window
  143.  
  144. 5. Create a vimrc startup script to keep your preferred settings.
  145.  
  146. 6. When typing a : command, press CTRL-D to see possible completions.
  147. Press <TAB> to use one completion.
  148.  
  149. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  150.  
  151. Ctag
  152.  
  153. 1. install ctags
  154. 2. ctags -R . (recursively initialize ctags for project folder)
  155. 3. check git status (ctags folder should be presence)
  156. 4. echo tags >> .git/info/exclude (add this folder to git ignore file)
  157. 5. check git status (tracking should be gone)
  158.  
  159. Ctrl+] - go to definition
  160. Ctrl+T - Jump back from the definition.
  161. Ctrl+W Ctrl+] - Open the definition in a horizontal split
  162.  
  163. Add these lines in vimrc
  164. map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
  165. map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
  166.  
  167. Ctrl+\ - Open the definition in a new tab
  168. Alt+] - Open the definition in a vertical split
  169.  
  170. After the tags are generated. You can use the following keys to tag into and tag out of functions:
  171.  
  172. Ctrl+Left MouseClick - Go to definition
  173. Ctrl+Right MouseClick - Jump back from definition
  174.  
  175. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  176.  
  177.  
  178. Easy combination for delete word inside and around double or single quotes
  179.  
  180.  
  181. 1. daw (delete around double quotes - all together)
  182. 2. caw
  183.  
  184. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  185. Jumps between lines and files
  186.  
  187. 1. G (go to beginning of the line)
  188. 2. ga (come back on position before action - recording jumps)
  189. 3. ^o (jump back)
  190. 4. ^i (jump forward)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement