Professional Documents
Culture Documents
Vim Workshop
Vim Workshop
1
@nicknisi
2
3
❤ WebStorm Vim
4
@nicknisi
5
But I NEED an IDE
6
No you don't
7
Why vim?
4 highly customizable
4 runs everywhere
4 works with many programming
languages
4 scriptable
8
Install vim
9
(it's probably already there)
10
brew install macvim --override-system-vim
11
Features
12
Modal editing
13
Modal editing
Change the meaning of the keys in each mode of operation
16
DON'T USE THE MOUSE
17
You're a programmer.
Strive to be lazy.
18
hjkl
left 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 file
20
Elite!
21
The secret sauce
22
The secret sauce
4 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 objects
4 w - words
4 s - sentences
4 p - paragraphs
4 t - tags1
1
tags available in XML/HTML files
26
Motions
4 a- all
4 i - in
4 t - 'til
4 f - find forward
4 F - find backward
27
Combine with comands
28
Commands
4 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
diw
delete in word
31
caw
change all word
32
yi)
yank all text inside parentheses
33
va"
visually select all inside doublequotes
Including doublequotes
34
Repetition
The DOT command
.
35
Repeat the last command
36
that's it
37
but it's powerful
38
Additional commands
4 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 it
40
Not everything is repeatable
at least with the DOT command
41
MACROS
42
Macro
A sequence of commands recorded to a register
43
Record a macro
4 q{register}
4 (do the things)
4 q
Play a macro
4 @{register}
44
Plugins
45
Plugins
4 vundle - plugin manager
4 nerdtree - file drawer
4 ctrlp - fuzzy file finder
4 fugitive - git tool
4 syntastic - syntax checker / linter
46
But My IDE does more
47
Vim is extemely customizable
Plugins tailor vim to your needs
48
But we can still do more
49
50
vim + tmux
51
tmux
brew 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+a
unbind C-b
set -g prefix C-a
bind 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 = ❤
60
benmills/vimux
Interact with tmux from vim
61
Execute commands from vim in a split
:call VimuxRunCommand("grunt test")
62
I ❤ vim
and I think you will, too
63
Learn your editor well
(even if it's not vim)
64
Don't copy someone else's configuration
Make it your own
65
But share your configuration
66
dotfiles
4 Share your configuration
4 Steal ideas from others
4 nicknisi/dotfiles
67
Keep practicing
68
❤
https://github.com/nicknisi/vim-workshop
69