Vimtroduction Real Presentation
-
Upload
ahmad-ibrahim-maruf -
Category
Documents
-
view
214 -
download
0
Transcript of Vimtroduction Real Presentation
-
8/12/2019 Vimtroduction Real Presentation
1/41
-
8/12/2019 Vimtroduction Real Presentation
2/41
What is Vim?Vim is a multiplatform, massively configu
extensible, modal text editor
Notan IDE A console application (in its best and tr
form)
Vi improved
-
8/12/2019 Vimtroduction Real Presentation
3/41
Why is Vim? Employ muscle memory to edit code
at the speed of thought
Edit code, configuration files, log files, amuch more identically
Make it the perfect IDE for you Integration with command line Feel superior to other people! Fun!
-
8/12/2019 Vimtroduction Real Presentation
4/41
A modalinterface
Obtuse hotkeys andcommands
Enormous set of commands Easy to hit the wrong key
when learning
Why is Vim hard?
-
8/12/2019 Vimtroduction Real Presentation
5/41
A modalinterface
Obtuse hotkeys andcommands
Enormous set of commands Easy to hit the wrong key
when learning
but you should und
by the end of this l
theres actually log
almost every hotke
but you only need
fewwell go over incan
fix whatever you m
Why is Vim not actually that
-
8/12/2019 Vimtroduction Real Presentation
6/41
Opening and Closing VimTo open Vim from a terminal:
! #$% &$'()*+*
To close Vim (and save your work):
,-./01*(23
-
8/12/2019 Vimtroduction Real Presentation
7/41
The VimInterCursor
Status Line
Cursor P
-
8/12/2019 Vimtroduction Real Presentation
8/41
The VimInter
Were in Insert Mode
-
8/12/2019 Vimtroduction Real Presentation
9/41
The VimInter
Typing a command
-
8/12/2019 Vimtroduction Real Presentation
10/41
Why have modes?
(# of keys) (# of modes) = More Hotkeys
The only modes you really need to know:
Normal Mode home base / comma
entry
Insert Mode add text to do
Visual Mode select text
Modes
-
8/12/2019 Vimtroduction Real Presentation
11/41
Point your browsers to
coolwanglu.github.io/vim.js/web/vim.h
Lets do it!
-
8/12/2019 Vimtroduction Real Presentation
12/41
Use hjkl to move around the document:
45 67 89 :'
Moving Around the Docum
-
8/12/2019 Vimtroduction Real Presentation
13/41
Hit $to enter Insert Mode, then type.
Hit /0;
-
8/12/2019 Vimtroduction Real Presentation
14/41
A motionis a hotkey for moving the curso
Important motions:
Next !ord / "ack a word
#nd of word
$- first non-whitespace character on line
%- last character on line
Motions
-
8/12/2019 Vimtroduction Real Presentation
15/41
VerbsA verb, as you learned in grade school, is
action word. Verbs in Vim are how we ch
the document.
Examples:
&elete - (requires a motion argument)
'ank - copy text
(aste - paste text at cursor position
-
8/12/2019 Vimtroduction Real Presentation
16/41
VerbsA verb, as you learned in grade school, is
action word. Verbs in Vim are how we ch
the document.
Examples:
)hange - delete & enter insemode
*pen new line
-
8/12/2019 Vimtroduction Real Presentation
17/41
SentencesThe Vimpoweruser uses compound actio
which can be thought of like sentences.
[verb][# of times to repeat][motion
Examples:
dw = ?
y2w = ?
-
8/12/2019 Vimtroduction Real Presentation
18/41
SentencesThe Vimpoweruser uses compound actio
which can be thought of like sentences.
[verb][# of times to repeat][motion
Examples:
dw = Delete word
y2w = ?
-
8/12/2019 Vimtroduction Real Presentation
19/41
SentencesThe Vimpoweruser uses compound actio
which can be thought of like sentences.
[verb][# of times to repeat][motion
Examples:
dw = Delete word
y2w = Yank 2 words
-
8/12/2019 Vimtroduction Real Presentation
20/41
-
8/12/2019 Vimtroduction Real Presentation
21/41
-
8/12/2019 Vimtroduction Real Presentation
22/41
Advanced MotionsNow, lets look at more sophisticated way
moving around the document.
+ind[_] - move cursor to next [_] o
,ill[_] - move cursor beforenext [_] on
Examples:
+- = Move cursor to next m on line
&.,/ = Delete until just beforethe seco
following
-
8/12/2019 Vimtroduction Real Presentation
23/41
Vim LogicThere are a few patterns in hotkeys that are worth n
For verbs, doubling the hotkey applies it to the entir
'' - yank entire row
)) - delete all characters on row and open I
If an action works forwards, capitalize it to do the sa
backwards:
(/ 0 - paste aercursor / paste beforecurso
*/ 1 - open line aercurrent / open line befo
+/ 2 - find letter forwards / find letter backw
-
8/12/2019 Vimtroduction Real Presentation
24/41
Putting it all togetheHere are some of my most-used compound actions
&& - ?
&% - ?
),3 - ?
)45 - ?
&6 - ?
-
8/12/2019 Vimtroduction Real Presentation
25/41
Putting it all togetheHere are some of my most-used sentences
&& - delete current line
&% - ?
),3 - ?
)45 - ?
&6 - ?
-
8/12/2019 Vimtroduction Real Presentation
26/41
Putting it all togetheHere are some of my most-used sentences
&& - delete current line
&% - delete until end of current line
),3 - ?
)45 - ?
&6 - ?
-
8/12/2019 Vimtroduction Real Presentation
27/41
Putting it all togetheHere are some of my most-used sentences
&& - delete current line&% - delete until end of current line
),3 - delete all characters on line unt
semicolon, then enter Insert Mode
)45 - ?
&6 - ?
-
8/12/2019 Vimtroduction Real Presentation
28/41
-
8/12/2019 Vimtroduction Real Presentation
29/41
Putting it all togetheHere are some of my most-used sentences
&& - delete current line&% - delete until end of current line
),3 - delete all characters on line unt
semicolon, then enter Insert Mode
)45 - delete all characters 4nside
parenthesis, then enter Insert Mode
&6 - delete until end of document
-
8/12/2019 Vimtroduction Real Presentation
30/41
Copy / PasteAnything you yank, as well as anything you
is automatically copied to a register. Yousee the current contents of the registers
typing
,2(=$;*(2;/01*(23in Normal Mode.
To paste aerthe cursor, hit (in Normal
or hit 0 to paste before the cursor
-
8/12/2019 Vimtroduction Real Presentation
31/41
Any action, or command that changes the
document, can be undone or redone.
Not insertion of a single letter - everything
between entering and exiting Insert Mod
To undo, hit 7in Normal Mode. To redo, h;
-
8/12/2019 Vimtroduction Real Presentation
32/41
Vims most bizarre and beautiful hotkey:
To redo again, hit /You can also provide a number argument
Examples:(Last action is .&!), >/ = ?
(Last action is )!, then we typed dog, then returne
Normal Mode), / = ?
Undo / Redo
-
8/12/2019 Vimtroduction Real Presentation
33/41
Vims most bizarre and beautiful hotkey:
To redo again, hit /You can also provide a number argument
Examples:(Last action is .&!), >/ = delete 8 more wo
(Last action is )!, then we typed dog, then returne
Normal Mode), / = ?
Undo / Redo
-
8/12/2019 Vimtroduction Real Presentation
34/41
Vims most bizarre and beautiful hotkey:
To redo again, hit /You can also provide a number argument
Examples:(Last action is .&!), >/ = delete 8 more wo
(Last action is )!, then we typed dog, then returne
Normal Mode), / = replace next word
dog
Undo / Redo
-
8/12/2019 Vimtroduction Real Presentation
35/41
CommandsTo enter commands, be in Normal Mode,
then hit ?to open up the command line.Tab for autocompletion of commands and files work
Examples:
:w(rite) - saves current document:sav(e) la.js - saves current document
la.js instead of previous filen
:r(ead) some.cpp - inserts contents o
some.cpp here
-
8/12/2019 Vimtroduction Real Presentation
36/41
To enter commands, be in Normal Mode,
then hit ?to open up the command line.
The only one you absolutely must know:
:h(elp) [topic] - opens help page etopic
Commands
-
8/12/2019 Vimtroduction Real Presentation
37/41
If something weird just happened, here ar
standard things to try.
Issue
IncantationSomehow, I deleted everything! Undo with 7
Some window popped up! ?@ABC,#9D
WTF is Replace Mode? ABE)D
What Just Happened
-
8/12/2019 Vimtroduction Real Presentation
38/41
Topics for Next Week Autocompletion Marks and Folding Command Line Integration Search / Replace Global commands Multiple Insertion with Visual Block Mode Vim Plugins Configuring Vim / Ftplugin
Snippets!
-
8/12/2019 Vimtroduction Real Presentation
39/41
How To Learn More Use :help [topic] Play around! StackOverflow for specific topics vim-adventures.com vimgolf.com vim.wikia.com/wiki/Vim_Tips_Wiki
-
8/12/2019 Vimtroduction Real Presentation
40/41
1. Install Vima. Linux - you already have it.b. Windows - ftp://ftp.vim.org/pub/vim/pc/gvimc. Mac - code.google.com/p/macvim/
2. Open Vimtutora. Linux - ! #$%*>*?2b. Mac - ! #$% @>;2@;5A2(@#$%@#$%BC@*>*?2@*c. Windows - run gVim, then openD,EF2?=2A% G$'(;E
E#$%BCE*>*?2E*>*?2
Lets Try Vimtutor
-
8/12/2019 Vimtroduction Real Presentation
41/41
Thanks for coming,
and happy Vimming