forked from VirajParab/dot_files
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimSecrets.txt
106 lines (60 loc) · 3.27 KB
/
vimSecrets.txt
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
Vim Secrets
- :w !sudo tee % - save the file which need sudo permission
- :earlier 15m - reverts the document back to how it was 15 min before
- :later 15m - opposite to reverts
- :! [command] executes an external command while you're in Vim.
- :help text-objects
- ci" - cuts the text in current quotes
- C - cut the rest of the line and switch to insert mode."
- ZZ -- save and close current file (WAY faster than Ctrl-F4 to close the current tab!)
- ddp - move current line one row down
- xp -- move current character one position to the right
- U - uppercase, so viwU upercases the word
- ~ - switches case, so viw~ will reverse casing of entire word
- Ctrl+u / Ctrl+d:- scroll the page half-a-screen up or down. This seems to be more
useful than the usual full-screen paging as it makes it easier to see how the
two screens relate. For those who still want to scroll entire screen at a time
there's Ctrl+f for Forward and Ctrl+b for Backward. Ctrl+Y and Ctrl+E scroll
down or up one line at a time.
- zz -- it scrolls the screen to make this line appear in the middle. This is
excellent for putting the piece of code you're working on in the center of
your attention. Sibling commands -- zt and zb -- make this line the top or
the bottom one on the sreen which is not quite as useful.
- % finds and jumps to the matching parenthesis.
- de -- delete from cursor to the end of the word (you can also do dE to delete
until the next space)
- bde -- delete the current word, from left to right delimiter
- dt. -- delete until next dot
- dd -- delete this entire line
- ye (or yE) -- yanks text from here to the end of the word
- ce - cuts through the end of the word
- bye -- copies current word
- yy -- copies the current line
- cc -- cuts the current line, you can also do S instead. There's also lower
cap s which cuts current character and switches to insert mode.
- :%!xxd - Make vim into a hex editor. revert - :%!xxd -r
- g; and g, - move (forward, backward) through the changelist.
- Sometimes a setting in your .vimrc will get overridden by a plugin or
autocommand. To debug this a useful trick is to use the :verbose command in
conjunction with :set. For example, to figure out where cindent got
set/unset: :verbose set cindent?
- gv :- Reselects last visual selection.
- q: :- browse through command history.
- :%TOhtml : Creates an html rendering of the current file.
- Vim will open a URL, for example : vim http://stackoverflow.com/
- :e ++enc=cp1250 %:p :- reopen the current file with a different encoding:
- ^O and ^I : Go to older/newer position.
- gi : Go to position where Insert mode was stopped last
- gf : put cursor on file name (e.g. include header file), press gf and the
file is opened
- I :- Jump to beginning of the current line and enter insert mode.
- A :- Jump to end of the current line and enter insert mode.
- O :- Add a blank line before current line and enter insert mode on that line.
- >> - Indent current line.
- << - Dedent current line.
- :ls :- List open buffers.
- :bd :- Close current buffer.
- zo :- Open current fold under the cursor.
- zc :- Close current fold under the cursor.
- zR :- Open all folds. This sets 'foldlevel' to highest fold level.
- zM :- Close all folds: set 'foldlevel' to 0.