SlideShare uma empresa Scribd logo
1 de 56
Baixar para ler offline
Vim - The Hacker’s Editor
Vysakh Sreenivasan
vysakh.quora.com
vysakh0 - twitter/facebook
April 29, 2013
Vim
Table of Contents
1 Vim
History
Vi Basics
Advanced
Plugins
Resources and Links
Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 2 / 35
Vim
Billion Dollar Editor
Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 3 / 35
Vim
What is the big deal?
Vi, that got its 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
Vim
What is the big deal?
Vi, that got its 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
Vim
What is the big deal?
Vi, that got its 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
Vim
What is the big deal?
Vi, that got its 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
Vim
What is the big deal?
Vi, that got its 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
Vim
What is the big deal?
Vi, that got its 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
Vim
How do Vim users feel :)
Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 5 / 35
Vim History
Line and Screen Editors
History of Text editors in a nutshell
Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 6 / 35
Vim History
Line and Screen Editors
History of Text editors 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
Vim History
Line and Screen Editors
History of Text editors 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
Vim History
Line and Screen Editors
History of Text editors 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
Vim History
Line and Screen Editors
History of Text editors 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 Vi Basics
Fire up Vim
vim filename
Opens up 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
Vim Vi Basics
Modes
Insert - Only for typing!!!
i 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
Vim Vi Basics
Modes contd..
Ex mode - Similar to 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
Vim Vi Basics
Panes
ctrl+w+s or :sp - split horizontally
ctrl+w+v or :vsp - split vertically
ctrl+w+w - move next pane
Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 10 / 35
Vim Vi Basics
Tabs
:tabe filename To open a file in a new tab
gt To move to next tab
gT To move to prev tab
Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 11 / 35
Vim Vi Basics
Movements
j - points downwards!
k - the straight k line points upwards
Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 12 / 35
Vim Vi Basics
More on Movements..
gg - go to 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
Vim Vi Basics
More on Movements..
w - go to 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
Vim Vi Basics
Copy/Delete/Paste
y - yank/copyies, yy - copies 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
Vim Vi Basics
Combination of keys
Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 16 / 35
Vim Vi Basics
Combination of keys
10p - paste ten 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
Vim Vi Basics
More on key combo
diw - delete 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
Vim Vi Basics
Search, Replace
Search /searchword
Search current word *
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
Vim Vi Basics
Play around with ex editor/ex mode
ex 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
Vim Vi Basics
Play around with ex editor/ex mode
ex 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
Vim Vi Basics
Play around with ex editor/ex mode
ex 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
Vim Vi Basics
Play around with ex editor/ex mode
ex 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
Vim Vi Basics
Play around with ex editor/ex mode
ex 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
Vim Vi Basics
Play around with ex editor/ex mode
ex 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
Vim Vi Basics
Play around with ex editor/ex mode
ex 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
Vim Vi Basics
t$ (copy current line to the end 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
Vim Vi Basics
t$ (copy current line to the end 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
Vim Vi Basics
t$ (copy current line to the end 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
Vim Vi Basics
t$ (copy current line to the end 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
Vim Vi Basics
t$ (copy current line to the end 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
Vim Vi Basics
t$ (copy current line to the end 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
Vim Vi Basics
t$ (copy current line to the end 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
Vim Vi Basics
tip
Ctrl+w
in insert mode will backspace 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
Vim Advanced
Omni complete
Ctrl + n or Ctrl + 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
Vim Advanced
Macros
Records set of actions - qm or 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
Vim Advanced
Marks
Mark your position in the file - 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
Vim Advanced
Jumps
Ctrl + o - to go the 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
Vim Advanced
Registers
”kyy - Copying the current line to 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
Vim Advanced
norm in ex mode
:1,3 norm I Wow
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 Advanced
What we have learnt now?
Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 29 / 35
Vim Plugins
.vimrc
The file .vimrc
You could customize your vim setup
Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 30 / 35
Vim Plugins
Plugins - installation
Plugin Managers
Use Vundle.(latest one) or Pathogen.
Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 31 / 35
Vim Plugins
Plugins I use
NERDTree
Nerdcommenter
Ctrl+P
dwm
surround
snipmate
rails.vim
supertab
LaTeXBox
Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 32 / 35
Vim Plugins
New Plugins which is worth a try
gist 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
Vim Resources and Links
Learn Vim
vimtutor (in terminal after installing Vim)
:help thingyouwantosearch (inside Vim)
openvim.com
vimcasts.com
usevim.org
plenty more
Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 34 / 35
Vim Resources and Links
Why waiting?
Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 35 / 35

Mais conteúdo relacionado

Mais de Vysakh Sreenivasan

Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)Vysakh Sreenivasan
 
A limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced RubyA limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced RubyVysakh Sreenivasan
 
Building Rich Ruby on Rails with Emberjs
Building Rich Ruby on Rails with EmberjsBuilding Rich Ruby on Rails with Emberjs
Building Rich Ruby on Rails with EmberjsVysakh Sreenivasan
 

Mais de Vysakh Sreenivasan (6)

Caching in rails
Caching in railsCaching in rails
Caching in rails
 
Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)Testing Ruby with Rspec (a beginner's guide)
Testing Ruby with Rspec (a beginner's guide)
 
A limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced RubyA limited guide to intermediate and advanced Ruby
A limited guide to intermediate and advanced Ruby
 
Ruby on Rails for beginners
Ruby on Rails for beginnersRuby on Rails for beginners
Ruby on Rails for beginners
 
What's new in Rails 4.1
What's new in Rails 4.1What's new in Rails 4.1
What's new in Rails 4.1
 
Building Rich Ruby on Rails with Emberjs
Building Rich Ruby on Rails with EmberjsBuilding Rich Ruby on Rails with Emberjs
Building Rich Ruby on Rails with Emberjs
 

Último

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 

Último (20)

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 

Introduction to vim

  • 1. Vim - The Hacker’s Editor Vysakh Sreenivasan vysakh.quora.com vysakh0 - twitter/facebook April 29, 2013
  • 2. Vim Table of Contents 1 Vim History Vi Basics Advanced Plugins Resources and Links Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 2 / 35
  • 3. Vim Billion Dollar Editor Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 3 / 35
  • 4. Vim What is the big deal? Vi, that got its 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
  • 5. Vim What is the big deal? Vi, that got its 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
  • 6. Vim What is the big deal? Vi, that got its 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
  • 7. Vim What is the big deal? Vi, that got its 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
  • 8. Vim What is the big deal? Vi, that got its 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
  • 9. Vim What is the big deal? Vi, that got its 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
  • 10. Vim How do Vim users feel :) Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 5 / 35
  • 11. Vim History Line and Screen Editors History of Text editors in a nutshell Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 6 / 35
  • 12. Vim History Line and Screen Editors History of Text editors 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
  • 13. Vim History Line and Screen Editors History of Text editors 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
  • 14. Vim History Line and Screen Editors History of Text editors 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
  • 15. Vim History Line and Screen Editors History of Text editors 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
  • 16. Vim Vi Basics Fire up Vim vim filename Opens up 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
  • 17. Vim Vi Basics Modes Insert - Only for typing!!! i 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
  • 18. Vim Vi Basics Modes contd.. Ex mode - Similar to 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
  • 19. Vim Vi Basics Panes ctrl+w+s or :sp - split horizontally ctrl+w+v or :vsp - split vertically ctrl+w+w - move next pane Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 10 / 35
  • 20. Vim Vi Basics Tabs :tabe filename To open a file in a new tab gt To move to next tab gT To move to prev tab Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 11 / 35
  • 21. Vim Vi Basics Movements j - points downwards! k - the straight k line points upwards Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 12 / 35
  • 22. Vim Vi Basics More on Movements.. gg - go to 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
  • 23. Vim Vi Basics More on Movements.. w - go to 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
  • 24. Vim Vi Basics Copy/Delete/Paste y - yank/copyies, yy - copies 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
  • 25. Vim Vi Basics Combination of keys Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 16 / 35
  • 26. Vim Vi Basics Combination of keys 10p - paste ten 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
  • 27. Vim Vi Basics More on key combo diw - delete 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
  • 28. Vim Vi Basics Search, Replace Search /searchword Search current word * 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
  • 29. Vim Vi Basics Play around with ex editor/ex mode ex 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
  • 30. Vim Vi Basics Play around with ex editor/ex mode ex 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
  • 31. Vim Vi Basics Play around with ex editor/ex mode ex 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
  • 32. Vim Vi Basics Play around with ex editor/ex mode ex 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
  • 33. Vim Vi Basics Play around with ex editor/ex mode ex 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
  • 34. Vim Vi Basics Play around with ex editor/ex mode ex 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
  • 35. Vim Vi Basics Play around with ex editor/ex mode ex 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
  • 36. Vim Vi Basics t$ (copy current line to the end 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
  • 37. Vim Vi Basics t$ (copy current line to the end 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
  • 38. Vim Vi Basics t$ (copy current line to the end 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
  • 39. Vim Vi Basics t$ (copy current line to the end 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
  • 40. Vim Vi Basics t$ (copy current line to the end 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
  • 41. Vim Vi Basics t$ (copy current line to the end 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
  • 42. Vim Vi Basics t$ (copy current line to the end 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
  • 43. Vim Vi Basics tip Ctrl+w in insert mode will backspace 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
  • 44. Vim Advanced Omni complete Ctrl + n or Ctrl + 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
  • 45. Vim Advanced Macros Records set of actions - qm or 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
  • 46. Vim Advanced Marks Mark your position in the file - 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
  • 47. Vim Advanced Jumps Ctrl + o - to go the 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
  • 48. Vim Advanced Registers ”kyy - Copying the current line to 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
  • 49. Vim Advanced norm in ex mode :1,3 norm I Wow 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
  • 50. Vim Advanced What we have learnt now? Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 29 / 35
  • 51. Vim Plugins .vimrc The file .vimrc You could customize your vim setup Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 30 / 35
  • 52. Vim Plugins Plugins - installation Plugin Managers Use Vundle.(latest one) or Pathogen. Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 31 / 35
  • 53. Vim Plugins Plugins I use NERDTree Nerdcommenter Ctrl+P dwm surround snipmate rails.vim supertab LaTeXBox Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 32 / 35
  • 54. Vim Plugins New Plugins which is worth a try gist 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
  • 55. Vim Resources and Links Learn Vim vimtutor (in terminal after installing Vim) :help thingyouwantosearch (inside Vim) openvim.com vimcasts.com usevim.org plenty more Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 34 / 35
  • 56. Vim Resources and Links Why waiting? Vysakh Sreenivasan (vysakh.quora.com) Vim - The Hacker’s Editor April 29, 2013 35 / 35