SlideShare ist ein Scribd-Unternehmen logo
1 von 56
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Kürzlich hochgeladen (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

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