Vim Workshop
-
Upload
robert-cooper -
Category
Documents
-
view
43 -
download
6
description
Transcript of Vim Workshop
-
WebStorm1
-
@nicknisi
2
https://twitter.com/nicknisi -
3
-
WebStorm Vim
4
-
@nicknisi
5
https://twitter.com/nicknisi -
But I NEED an IDE
6
-
No you don't7
-
Why vim?4 highly customizable
4 runs everywhere
4 works with many programming languages
4 scriptable
8
-
I! st" ll #im9
-
(i ! s " ro#ab$y %lr&ad t ( er&)
1!
-
brew install macvim --override-system-vim
1!
-
F!at" re#1!
-
M! da" e#it $ng1!
-
Modal editingChange the meaning of the keys in each mode of operation
4 Normal mode - navigate the structure of the file
4 Insert mode - editing the file
4 Visual mode - highlight portions of the file to manipulate at once
4 Ex mode - command mode14
-
Normal mode15
-
DON'T USE ARROW KEYS
16
-
DON'T USE THE MOUSE
17
-
You're a programmer. Strive to be lazy.
18
-
h j k lleft up down right
19
-
4 ^E - scroll the window down
4 ^Y - scroll the window up
4 ^F - scroll down one page
4 ^B - scroll up one page
4 H - move cursor to the top of the window
4 M - move cursor to the middle of the window
4 L - move cursor to the bottom of the window
4 gg - go to top of file20
-
Elite!21
-
The secret sauce
22
-
The secret sauce4 text objects and motions
4 the DOT command
4 macros
23
-
Text objects and motions
24
-
Think of a file as more than individual characters
25
-
text objects4 w - words
4 s - sentences
4 p - paragraphs
4 t - tags1
1 tags available in XML/HTML files
26
-
Motions4 a- all
4 i - in
4 t - 'til
4 f - find forward
4 F - find backward
27
-
Combine with comands
28
-
Commands4 d - delete (also cut)
4 c - change (delete, then place in insert mode)
4 y - yank (copy)
4 v - visually select
29
-
{command}{text object or motion}
30
-
diwdelete in word
31
-
cawchange all word
32
-
yi)yank all text inside parentheses
33
-
va"visually select all inside doublequotes
Including doublequotes34
-
RepetitionThe DOT command
.
35
-
Repeat the last command
36
-
t hats it37
-
but it's powerful38
-
Additional commands4 dd / yy - delete/yank the current line
4 D / C - delete/change until end of line
4 ^ / $ - move to the beginning/end of line
4 I / A - move to the beginning/end of line and insert
4 o / O - insert new line above/below current line and insert
39
-
Try and make actions repeatable
Practice it40
-
Not everything is repeatableat least with the DOT command
41
-
MACROS42
-
M! cr"A !eq"en#e $f #om%an&s ec$rd(d )o * r(gi! te
4!
-
R!co"d # m#cr$
4 q{register}
4 (d ! " h# t $%&()
4 q
P!ay " m"cr#
4 @{register}
4!
-
Plugins45
-
Plugins4 vundle - plugin manager
4 nerdtree - file drawer
4 ctrlp - fuzzy file finder
4 fugitive - git tool
4 syntastic - syntax checker / linter
4!
https://github.com/gmarik/vundlehttps://github.com/scrooloose/nerdtreehttps://github.com/kien/ctrlp.vimhttps://github.com/tpope/vim-fugitivehttps://github.com/scrooloose/syntastic -
B! t " y #DE $oe% m&re
4!
-
V!m !s "xt"me#y $us%om!za&leP!ug"ns #ai!or $im #o %ou& n ed(
4!
-
B! t " e #an $ti %l &o or(
4!
-
5 !
-
v!m + t" ux5 !
-
tmuxbrew install tmux
52
-
What is tmux?4 Terminal multiplexer
4 View and control multiple consoles
4 Preconfigure environments
53
-
tmux new-session -s {session-name}
54
-
tmux new-session -s pasta
55
-
~/.tmux.conf - tmux configuration
4 configure tmux# unbind default prefix and set it to Ctrl+aunbind C-bset -g prefix C-abind C-a send-prefix
56
-
There's a lot that tmux can do
57
-
Synchronize-panes
58
-
Create splits on the fly
59
-
tmux + vim = 6 !
-
b!nm"ll#/v "mu$I! te"ac# w$th #mu% f"om &im
6 !
https://github.com/benmills/vimux -
E! ec" te #om$an%s &ro$ vm n ( s) li*:call VimuxRunCommand("grunt test")
M! p "he #om$an%s "o ! k&ynmap z :call VimuxRunCommand("grunt test")
6 !
-
I ! v!ma! d " t #in$ y%u &il, t%o
6 !
-
L!ar" y#ur !di$or %el&(e! en "f "ts #ot ! im)
6 !
-
D! nt "op# s! me! ne $ls$s "on%g&ra io(
M! ke "t #ou$ o%n
6 !
-
But share your configuration
66
-
dotfiles4 S!"#$ %&u# c() g*+,-./ n
4 S01,2 i31,4 56o7 o0896:
4 n.; i/d?) l@>
6 !
https://github.com/nicknisi/dotfiles -
K!ep " ra#ti #in$
6 !
-
!h! tp "://g #th$b.c%m/n#ck&is#/v#m-w%rk"ho
6 !
https://github.com/nicknisi/vim-workshop