start in 1976.- Grand Daddy! Moving: if IDEs walk, vim swings Default in most OSes Increases Productivity!! Most Hackers use! The last editor you would use! Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 4 / 35
start in 1976.- Grand Daddy! Moving: if IDEs walk, vim swings Default in most OSes Increases Productivity!! Most Hackers use! The last editor you would use! Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 4 / 35
start in 1976.- Grand Daddy! Moving: if IDEs walk, vim swings Default in most OSes Increases Productivity!! Most Hackers use! The last editor you would use! Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 4 / 35
start in 1976.- Grand Daddy! Moving: if IDEs walk, vim swings Default in most OSes Increases Productivity!! Most Hackers use! The last editor you would use! Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 4 / 35
start in 1976.- Grand Daddy! Moving: if IDEs walk, vim swings Default in most OSes Increases Productivity!! Most Hackers use! The last editor you would use! Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 4 / 35
start in 1976.- Grand Daddy! Moving: if IDEs walk, vim swings Default in most OSes Increases Productivity!! Most Hackers use! The last editor you would use! Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 4 / 35
in a nutshell Basic Line editor - Ed editor - made by Ken Thompson Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 6 / 35
in a nutshell Basic Line editor - Ed editor - made by Ken Thompson Advanced line editor Ex editor Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 6 / 35
in a nutshell Basic Line editor - Ed editor - made by Ken Thompson Advanced line editor Ex editor Screen Editor - you could see stuff while editing :) Vi Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 6 / 35
in a nutshell Basic Line editor - Ed editor - made by Ken Thompson Advanced line editor Ex editor Screen Editor - you could see stuff while editing :) Vi An improved Vi - Vim Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 6 / 35
vim with a filename. :w - to save :q - to quit :wq or :x - to save and quit :q! - to quit without saving. :e filename - to open another file :r filename - to read content from one file into current file Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 7 / 35
to insert in the cursor position I to insert in the beginning of line a to append after cursor position A to append at the end of the line o to insert a new line below O to insert a new line above Command - delete/copy/paste/movement/.. Ctrl + C or Ctrl+ [ or esc Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 8 / 35
ex editor :wq - begins with a colon, followed by commands. :g/re/p - grep was inspired from ex editor. This prints the lines which has ”re” Visual - For Selection v Selects characters V Selects rows/lines Ctrl+v Selects block/column Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 9 / 35
first line G - go to last line 4G - go to 4th line { and } movements to the beginning or end of the paragraph respectively. ( and ) to beginning or end of the sentence. Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 13 / 35
the beginning of next word e - go to the end of the next word b - go the beginning of the previous word 0 - go to the beginning of the line $ - go to the end of the line Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 14 / 35
the line, yw - copies the word d - deletes, dd - deletes the line, dw - deletes the word c - change, cc deletes the line and go to insert mode p - paste the copied/deleted text x - delete character under the cursor X - delete character before the cursor Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 15 / 35
times. d$ - delete till the end of the line 4yw - copy four words ggdG - deletes the entire file (goes to first line (gg), starts deleting (d) till the last line G) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 17 / 35
the word where the cursor is in. dw - deletes letters from cursor till next word. ciw - changes the word where cursor is in. di’ d“ di{ di( di[ replaces words inside ’ ” { ( [ Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 18 / 35
* Search and Replace :%s/search/replace/g % - every lines (without that, only current line) s - substitute g - replace all occurences (without that, only first occurence) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 19 / 35
filename (will open the file) i (to insert words) . (in the next line will end inserting) p (to print current line) %p (to print all lines) a (to append at the bottom) . (full stop in next will end appending) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 20 / 35
filename (will open the file) i (to insert words) . (in the next line will end inserting) p (to print current line) %p (to print all lines) a (to append at the bottom) . (full stop in next will end appending) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 20 / 35
filename (will open the file) i (to insert words) . (in the next line will end inserting) p (to print current line) %p (to print all lines) a (to append at the bottom) . (full stop in next will end appending) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 20 / 35
filename (will open the file) i (to insert words) . (in the next line will end inserting) p (to print current line) %p (to print all lines) a (to append at the bottom) . (full stop in next will end appending) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 20 / 35
filename (will open the file) i (to insert words) . (in the next line will end inserting) p (to print current line) %p (to print all lines) a (to append at the bottom) . (full stop in next will end appending) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 20 / 35
filename (will open the file) i (to insert words) . (in the next line will end inserting) p (to print current line) %p (to print all lines) a (to append at the bottom) . (full stop in next will end appending) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 20 / 35
filename (will open the file) i (to insert words) . (in the next line will end inserting) p (to print current line) %p (to print all lines) a (to append at the bottom) . (full stop in next will end appending) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 20 / 35
of the file) 1,3m5 (move 1-3 lines after 5th line) c (to change the current line) w (to write/save changes) wq (to save and quit) q (to quit) e filename (to edit the file) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 21 / 35
of the file) 1,3m5 (move 1-3 lines after 5th line) c (to change the current line) w (to write/save changes) wq (to save and quit) q (to quit) e filename (to edit the file) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 21 / 35
of the file) 1,3m5 (move 1-3 lines after 5th line) c (to change the current line) w (to write/save changes) wq (to save and quit) q (to quit) e filename (to edit the file) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 21 / 35
of the file) 1,3m5 (move 1-3 lines after 5th line) c (to change the current line) w (to write/save changes) wq (to save and quit) q (to quit) e filename (to edit the file) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 21 / 35
of the file) 1,3m5 (move 1-3 lines after 5th line) c (to change the current line) w (to write/save changes) wq (to save and quit) q (to quit) e filename (to edit the file) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 21 / 35
of the file) 1,3m5 (move 1-3 lines after 5th line) c (to change the current line) w (to write/save changes) wq (to save and quit) q (to quit) e filename (to edit the file) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 21 / 35
of the file) 1,3m5 (move 1-3 lines after 5th line) c (to change the current line) w (to write/save changes) wq (to save and quit) q (to quit) e filename (to edit the file) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 21 / 35
the word you are typing. Also works in shell. J Capital j will join two lines. gf If the cursor is on a word sample, the command gf would open the file sample if it is present in current directory gi Go back to the place where you are editing. Handy command when you are in the middle of your typing and go to command mode to fix issues. Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 22 / 35
p (in insert mode, handy when calling functions) Ctrl + x + k - dictionary completion Ctrl + x + f - file name autocompletion Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 23 / 35
qa or qb (begin with q) To repeat the recorded macro - @m or @a or @b (begin with @ followed by the letter) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 24 / 35
ml or mb or mq (begin with m) Go to the marked position - ’l or ’b or ’q (begin with ’ followed by corresponding letter) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 25 / 35
previous position in your files. ctrl + i - to go to the next position in your files. :jumps - to see all the jumps Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 26 / 35
k register ”kp - Pasting the line from k register ”Kyy - Appending to the k register ”kp - Paste the lines from k register Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 27 / 35
This would add the add word Wow at the beginning of 1-3 lines :[range] norm [Commands] Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 28 / 35
vim Writing your gist files in Vim :D Etherpad vim Yup! Etherpad in Vim! :) Also check out remote pair programming using Vim In browser Vimium in Chrome! is way awesome. Pentadactly in Firefox. (not sure if it is active) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 33 / 35