-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path#Vimception
140 lines (122 loc) · 4.96 KB
/
#Vimception
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#Vimception
Vim Demo for the uninitiated: https://youtu.be/WyeNmUMZ7gY (press gx to open)
###intro
• Hello, I'm Jared
• Who's used Vim?
◦ Who's a complete beginner?
◦ Who know how to use Vim but doesn't?
◦ Who uses Vim or Emacs all the time?
###what is Vim?
• "Vim is a terminal text editor - basically what 90's hackers use. It's for autistic savants and no-one else"
— the general consensus on Vim to non-users.
• What vim users think: http://www.vim.org/images/0xbabaf000l.png
• Vi IMproved - a free, opensource text editor for unix.
• Vim aims to minimize the number of keystrokes.
• Base on vi which was designed to be used over slow terminals.
• First released publicly in 1991. (Vi released 1976)
###why use Vim (or another command line text editor such as Vim or Emacs)?
• vi - on all posix compliant systems
◦ if you know vim you can stumble you way around vi
• light on ram
◦ raw - 2mb
◦ with my plugins - 4mb
• speed
◦ no need to move your hand from the home keys - scrolling, selecting, moving the cursor
◦ changing blocks
◦ repeat action, and macros
◦ a layer has been removed between your brain and the code
• cross over to:
◦ ide
◦ terminal pager (used by less, man, etc)
◦ command line
◦ browser (vimium)
• customisability
◦ vimscript
◦ vim-gitgutter
◦ autopairs
◦ ctrl-p
▸ ignore files in setting
◦ vim-surround
◦ language specific pluging
▸ syntax highting, linting, completion, docs, etc
• speed of updates
◦ neovim
• bang!
◦ run your test with a shortcut
▸ put this in your .vimrc in the javascript autogroup and press `\t` to test the current file: `nnoremap <localleader>t :!npm test %`
• SSH into a dev box and do all coding in Vim
###why you wouldn't use Vim
• You can't touch type
• You prefer Emacs
• You are have an extremly urgent project due in 2 weeks
• Status quo bias in effect - consider the reversal test
###vi mode in the terminal
• if you're going to use Vim, it helps to set vi editing mode in the command line
####~/.inputrc
{{{sh
$include /etc/inputrc
set completion-ignore-case On
set editing-mode vi set keymap vi-command
# many more commands to be found here: http://linux.about.com/library/cmd/blcmdl3_readline.htm
# see also: http://ss64.com/bash/syntax-inputrc.html
$if mode=vi
set keymap vi-command
# these are for vi-command mode
Control-l: clear-screen
"H": vi-first-print
"L": end-of-line
set keymap vi-insert
# these are for vi-insert mode
Control-l: clear-screen
Control-p: previous-history
"jk": vi-movement-mode
$endif
}}}
###how to get started
• Remap Caps Lock to Ctrl
• The suggested order of addoption:
◦ movement keys and getting in and out of insert mode
▸ move a little: <esc><c-c>ia, hjkl (disable arrow keys if you have to)
▸ move a bit further: <c-d><c-u> w b $ ^ {}
▸ jump: fFtT;
▸ search: /?np
◦ operator pending keys:
▸ visual mode
▸ delete or change stuff: dc
◦ learn to use the clipboard
◦ install ctrl-p with pathogen
• Peepcode screencast - Smash into Vim (https://www.pluralsight.com/courses/smash-into-vim)
• http://www.openvim.com/tutorial.html
• https://vim-adventures.com/
• https://www.easysession.com/products/vim-vi-keyboard-cover
###how to get fast
• Get better at touch typing
◦ Put your weakest characters in your passwords
• Disable crutch keys (arrows, backspace, or any other key you use when you could use something faster)
◦ Don't hold, or press a key multiple times in a row (remap these keys to <nop> if you have to)
• install vimium extension in the chrome
◦ if weak at touch typing digits, enable the option "Use the link's name and numbers for link-hint filtering"
###example .vimrc
~/.vimrc
https://raw.githubusercontent.com/jazzabeanie/dotfiles/master/home/.vimrc
###tips
• run though the first half of learn vimscript the hard way to take your vimrc file to the next level.
• Useful remaps:
◦ remap jk and kj to <esc> " makes escaping easier
◦ remap H to ^ and L to $ " makes end/start of line movement more intuitive.
• shell loops done with Vim:
◦ generate the list `ls | vim -`
◦ transform the list into commands (regex is very useful here)
▸ `%s/^\(.*\)$/cp \1 prepend_\1/g` for example TODO: test this
◦ run it `:w ! sh`
◦ you could also pipe into vim to debug shell loops
• modeline (see `:help modeline`)
◦ Use this for settings specific to individual files, eg, `// vim:nomodifiable`
###vimscript
http://learnvimscriptthehardway.stevelosh.com/
Other unconfirmed potential resource:
• http://ricostacruz.com/cheatsheets/vimscript.html
• http://andrewscala.com/vimscript/
####Footer:
Written using vim-note (https://github.com/xolox/vim-notes)
View this repo in github (https://github.com/jazzabeanie/vimception)