Skip to content

Instantly share code, notes, and snippets.

@gautamrege
Created December 2, 2010 09:14
Show Gist options
  • Save gautamrege/725020 to your computer and use it in GitHub Desktop.
Save gautamrege/725020 to your computer and use it in GitHub Desktop.
VIM - presentation. Most frequently uses VIM shortcuts.
1. Why use VIM?
VIM rocks!
VI or VIM?
I hate the mouse!
I am a text person
I love touch-typing (huh - what is touch typing% again..)
You have production server with only SSH access!
2. Vim -- you already knew
Command mode & Insert mode
Page Scrolling
Line Editing
Word editing
Open / close / quit / undo
Blah. Blah. Blah.
3. WTF -- how am doing that in vim??
folding!! zc, za -- foldmethod=indent
yeah I know I am showing off.
4. Frequently used Scrolling Shortcuts
Ctrl-F - page down
Ctrl-B - page up
Ctrl-D - view page down
w - scroll forward a word at a time
b - scroll backwords a word at a time
W - scroll forward on spaces ignoreing punctuations like (), +_) (*&^ etc.
B - scroll backwords on spaces ignoreing punctuations like (), +_) (*&^ etc.
0 - start of line
$ - end of line
H - top of screen
L - bottom of screen
5. Quick editing
i - insert mode at cursor location
a - insert mode after the current character
A - insert mode at end of current line
o - insert mode on line below
O - insert mode in line above
s - change current charge in insert mode
r - replace a character but in command mode.
x - delete character
~ - toggle ChArAcTeR CaSE
6. Undo / Redo
. - repeat last action
u - undo last action
U - undo till last saved version!
Ctrl-R - redo last action
7. Copy / Cut / Paste
x - delete character
dw - delete word
D - delete till end of line
cw - change word (dw and insert mode)
C - change till end of line (D and insert mode)
dd - delete entire line
yw - yank word
y$ - yank from cursor till end of line
p - paste last buffer
. - repeat last action
8. Search
/<regex> - search in file
f - find character in line ahead of cursor
F - find character in line behind cursor
9. Marking code
m<char> - mark this line
'<char> - go till the mark
y'<char> - yank(copy) till mark
d'<char> - delete till mark
10. Buffers
"<char> - external buffer
"a10yy - yank 10 lines in buffer with mark a
"by'm - yank lines from cursor till mark-m to external buffer 'b'
11. Replace
:%s/<find-regex>/<replace-regex>/<options> - replace all over the document
:.,'ms/del/wel/g - replace from cursor till mark 'm all del with wel
r - replace current character
R - set Replace mode.
12. Macros (for the strong hearted)
Change the way your editer work
Store in .vimrc if you require to use this later
:map -- sequence of commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment