Mode:: Nouns

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Mode:

Normal mode — the default mode. You can type text commands and do navigation. To enter this mode press ESC

Command mode — editor commands (like save, open, etc.). To enter this mode press: “esc” key.

Insert/Edit mode — in this mode you can type text as in other editors. To enter this mode press i/I/a/A/o/O. To
exit this mode, press “esc” key.

Visual mode — here you can select text. To enter this mode press v / ctrl-v/ V (individual/blockwise/linewise), to
exit, use “esc” key.

VIM language
Nouns:
w — word

s — sentence

p — paragraph

b — (block/parentheses)

t — tag

{, }, (, ), [, ] — braces

", ' — quotes

Verbs:
v — visualize

c — change (delete text and switch VIM into insert mode)

d — delete and copy (delete text and does not change VIM mode)

y — yank (means copy)

Adverbs:
i — inside

a — around

t — till

f — till (inclusive)

Examples:
Pay attention that these commands may work by itself not as you expect. Moreover, when you create a
VIM sentence, it should be sufficient and all constructions should be on their place, otherwise, you will
get another result. Now let's create some easy VIM sentences as an example:
ciw — change inside word — deletes the whole word under cursor and switches to insert mode, unlike
cw which deletes a word from cursor to the end of this word.

cis — change inside sentence.

ci" — change inside " brace — deletes all text between " braces.

da} — delete around } brace — deletes all text inside curly braces including them.

vip — visual inside paragraph — selects all paragraph.

ctp — change till p — delete everything from here to the letter p.


function foo() { function bar() { // some code here } }

you want to remove all code inside {} of foo function. Using number modifier it is easy to do. Just type
2ci{ — change inside curly braces 2 times. After run the 2ci{ command, you’ll get:
function foo() {}

Number modifier works not only in sentences but it works almost everywhere:

5j — moves the cursor down 5 times.

2fK — moves the cursor to the second occurrence of litter k in the line.

2iHello <ESC> — insert Hello 2 times.

Work with multiple files togather in vim


$ vim file1 file2 file3

Then use :n or :prev to move among them. See which file are open with: args. To close all current files
and open a new file :n file4 (now only file4 is open)

To see a list of all current buffers :ls

To edit a new file :e file4

To switch between all open files, use :b myfile or :b #, bp (previous), bn (next).

Close a buffer :bd

Using windows
Ctrl-W s and Ctrl-W v (or :split and :vertical split (:sp and :vs)) to split the current window horizontally
and vertically.

Ctrl-W w to switch between open windows, and Ctrl-W h (or j or k or l) to navigate through open
windows.

Ctrl-W c to close the current window, and Ctrl-W o to close all other windows except the current one.

Starting vim with a -o or -O flag opens each file in its own split.
Ctag
To use vim + ctag,

1) Run ctag at in your source tree:


$ ctags –R . # should see a ctag file under the current directory.
Now you’re ready to use ctags in vim. One thing need to aware is the only works if you start vim
at the directory where the ctag file locates!

C-] : go to the definition of the function under cursor.

C-t : go back to the start of the tracking!

:tag func_name # go directly to the func_name definition, func_name can be regexp.

You might also like