Language of VIM/NEOVIM

The first thing that may come to your mind when I say language of vim is Vim Script.No that’s not what I am talking about.I am talking about the patterns of keystrokes that recur over and over through your use of vim.

 

Construct <A> , Single alphabets

These are most common and most basic of all constructs ,It serves as main building block in vocabulary of language you are about to learn.It includes all the commands that are used in normal ,command mode and visual mode and macros also because they registers in disguise.

yy
p
dd
v
A
B
k
c
@b

Construct <B>, [count]<A>

Construct B comes into picture when you want a action to be repeated several times.count or range is usually a positive integer.Almost every vim command supports repetition using count, there are some that behave differently form other, like appending a count to v or V will be multiplied 5 times the count or even entire file is selected if the file type is markdown .I don’t know why and or it is same with other types also.Works fine with text, php and python files,If you do know then please leave it in the comment section.

3yy
29dd
6A
9i
32v
5p
17@y
7W
12: "and soo no

 

Construct <C>,<A>[motion] or <A>[i|a][motion]

In order fully understand the working of this construct, you must be familiar with types of motion that vim offers.I won’t be going over them.It is also important to remember that this construct will not work with all commands you can experiment this construct on different commands.This construct does not work with Macros and for some constructs motion is insignificant.

cw
yW 
c$ 
dB
yiw
vap
di} "or di{
ci] "or ci[
ya)

 

Construct <D>, [count]<C>

The fourth construct is extension of 3rd one,sometimes I wonder how a simple text-editor written in a period of early days of computation is capable of such complex operations and can compete with just any other editor or IDE. Okay , back to the topic.This is same as construct C, with an added ability to be repeated using count.

5yw
20dw
2viw
23vi

 

Construct <E>, [count]”[char]<A> in normal or ctrl-r[char] in Insert/command mode

The odd one out , this construct is different from previous ones.It allows for only yank and paste operations.There is a catch , range only works in normal mode.primary use of this construct is to edit or delete content of a register, well why you might want to do that ? because Macros execute the content of registers.By the way if you want to know more about registers , please check this post.Small letter will overwrite previous content if any and caps variant of the alphabet will append new data to the existing data if any.There may be cases when you recorded a register which is just right but not completely what you want it to be and you don’t want to re-record macro.You can paste the contents of register make the changes and yank it back to same register.

"Insert or Command mode
<c-r>ap
<c-r>ayy
"Normal mode
"ap
"ayy

References

 
:help motion
:help text-objects
:help
:help count
:help @

Conclusion :

Your brain loves patterns and thing that can be easily related to what you already know. Vim is complex , you need years of practice to master it and even after all those year you find something that you didn’t know was possible or existed in vim.

"Normal mode 
i:wq"ayy@a 
"Insert mode
<c-r>a "The data inside registers is persistent

2 Responses to “Language of VIM/NEOVIM”

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

%d bloggers like this: