-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlearn-vim
84 lines (69 loc) · 3.79 KB
/
learn-vim
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
GENERAL
to get help type :h <any command>
like :h ]p
. can be used to repeat previous command
MAPPINGS
map is recursive, noremap is non recursive
map! is only for insert mode
INDENTATION
>> or << sets the indentation and then . can be used to repeat the direction of indentation
== also doesn something in vim. automated indentation. Didnt work in python. HTML and js might work.
How to set up different shift widths in python. html and js is to be searched.
]p is paste at current level of indentation instead of starting of the line.
instead of j if + is used to go down movememnt it straight away takes to first letter of the line. (first non white space letter)
TABS
to open multiple tabs in vim is -p flag while opening vim
vim -p afile anotherfile anotheranotherfile
to open another file from inside vim in a new tab use
:tabe newfile
to move to next tab use 'gt' command and 'gT' for previous file
these both gt and gT are loopable
to move directly to a tab use 1gt, 2gt ot xgt fot xth tab
Tabs can be reorganised. :tabm 2 takes the current tab to tab directly after 2nd one.
:tabm takes it directly to the last
COPYING TEXT
:-13,-9t. - copy the text between -13 and -9 lines and paste it at current position
SEARCH
q/ instead of just / opens up search history and search can be chosen from there
to access search history when you have already started typing the search terms, use ctrl-f
to search comments use /".*$, to search for only line comments, ignoring comments after the code in same lin use /^".*$
SEARCH AND REPLACE
:-13,-9s/orignialtest/replacedtest replaces the words in mentioned lines
:-13,.s/blah/bluh here . is current position so replace stuff in all lines between -13 and current one..
:s/u/uu does replace on single line
:%s/u/uu on whole file
The serarch term can be a regex
c flag can be done for confirmation. :s/w/ppp/c
i flag is for case insensitive search
g flag means global. all lines and all occurances in a line
There is gsearch facility for searching across files
DELETE TEXT
:-13,-12d - deletes the mentioned lines
da", da{, da( - delte around <delimiter>. this deletes around the text inside the delimiter and delimiter itself
MODIFY TEXT
:ci<delimiter> ci" will change everything inside the double quotes if you are in a double quote string
ci{ will change everything inside the curly braces you are in, and similarly ci(
this also works woth things other than delimiters like, w for word,
this also works with a instead of i which is around and includes delimiters
gi would take you to the position where you were in insert mode last time and open insert mode again.
this is for people to roam around, checkout stuff and then come back and work
SPLIT
:windo prefix to any command makes it applied to all opwn splits
:windo e! reloads all files and removing all unsaved changes
:windo %s/integer/float/g | w - makes the search and replace across splits and saves all the files
:only closes all other splits except the current context split
,- maximizes the current split to full window
,= restores the original layout by demaximizing the maximized window
MOVE AROUND
{ and } to move between paragraphs
% to move between matching braces or prenthesis
gg to start of the file
"fafeeaf" "oijoi"
TODO
:help text-objects
:vim django bundle
:fuzzy finding plugins for files. research which one is good and install it.
:start using pathogen like system to manage plugins
: start using modular vimrc using source and git repo files. Core modifications always stay in git repo.
:evernote vim
:move onenotes away from onenote to github repo and connect it with dropbox and vim