Vim’s language

Your device is available Vim, sure, so where does it come from?

  • Vim is a fairly popular text editor, launched in 1991 by Bram Moolenaar as an extended version of Vi written by Bill Joy . Vim stands for Vi IMproved , the name is enough to show that Vim has significant advances compared to his father Vi . One of the significant advances is the support for more operating systems, better code highlighting, support for screen splits and plugins, etc. Any further reference you can read here .
  • You may wonder, on your computer, whether you are installing micro or vim . I would like to confirm that it is almost certainly vim , although you often type vi filename . Most Linux distributions are considered to be the default vim, a substitute for the name of containment is quite brief. You can check the following. I work on an operating system running Ubuntu 14.04.

So essentially nothing micro vim.basic

Why is Vim?

Vim was born a long time ago and still exists and develops with a large user community. Maybe for many new learners, Vim is a very confusing editor. However, before rejecting Vim, find out why there are so many people who are and will use this tool for their main editor.

Personally, when I first used Vim, I still had the thought of other "text editing tools". It is using the keyboard arrow keys for moving, home , end keys to the beginning and end of the line. Highlight and copy paste with Ctrl + C, Ctrl + V. Sometimes use the mouse for other operations and use the mouse to turn on the menu bar.

Using this mindset in Vim will completely fail, because Vim is completely different from other tools. Using only jkl-; for cursor control can drive you crazy the first time you meet. However, believe me, Vim is designed great for … your hands. You don't have to reach far away to find the right button -> or beyond to the End button … And also, if you're familiar with Vim, there will be a day when you want everything to be Vim , and you will be like me, type jkl-; to go up and down in … Microsoft Word

So, simply, to work with Vim, you need to change your mind about the "text editor". Learn to get used to it, and gradually see its greatness.

This article is beyond the scope of introduction. Vim also expects you to be familiar with and use this tool fluently.

Vim's language

As mentioned above, you need to change your way of thinking when working with Vim. More impulsively, when working with Vim, "think" before "doing". I've seen people use the arrow keys or the mouse to move from the middle to the end of a line, only to delete the highlighted text. I have seen mouse users black out a whole text, only to delete the code between the {} and replace it with another code. Did you know that with Vim, just typing no more than 3 buttons is the job

In the picture above I do 2 things. One is to delete the extra character part of line 11 and 2 to change line 18-21 with the text // Changed . The first job, I type Shift + D. In the second job, I type ci { without an arrow key. You probably think, "Don't worry, remember those hot and stupid hot keys". But, uh really remember, what to do   I will teach you how to learn, then remember, then do the same thing as me. The only thing you need to know is a little … English

We come to Vim's language.

Note when following the instructions below

  • The highlighted area is the cursor position.
  • To avoid being affected by other plugins you install, I recommend you turn on vim without the .vimrc file . The syntax is as follows the NONE filename

Verb – Verb

Well, the language must have nouns, verbs, adjectives, adverbs right, some of these are already in the language.

Starting from the verb, here is Vim's verb table

Verb

English

Meaning

y

Yank

Meaning of copying

c

Change / Cut

Change content and allow new content to be inserted

d

Delete

Erase

p

Paste

Paste

f

Find

Search and move the character pointer found

t

Big

Search and move the cursor to the previously found character

i

Insert

Insert before the current cursor position. Move to insert mode

a

Append

Insert after the current cursor position. Move to insert mode

That means if you type the other characters in normal mode, you will get the results in the exact action you want. The following example.

Manipulation

Meaning

Text status

Đây là một văn bản . Another here.

y

Yank . Copy the selected text area

Đây là một tex t . Another here.

fr

Find r . Move to the letter r

Đây là một văn bản. Anothe r here.

p

Paste . Paste the selected area

Đây là một văn bản. Anothertex t here.

The upper verbs, in addition to lower case ( lower case ), when writing upper case ( upper case ), it makes sense – added to lower case mode. For example D instead of d would be to delete the whole line from the current location. I instead of i will be the insert in the first position of the line. A instead of a will be append to the last position of the line, …

Noun – Noun

Noun

English

w

Word

S

Sentence

p

Paragraph

b

Blog / parentheses

t

Tag

These are some of Vim's nouns. Or see how it works through the following example.

Manipulation

Meaning

Text status

This is a t ext. It is too short.

yw

Yank Word . Copy words starting from the cursor position.

This is a t ext. It is too short.

4w

Move 4 words

Đây là một văn bản. It is t oo short.

Shift + p

Paste before. Paste in front of the current character

Đây là một văn bản. It is texttoo short.

l

Move right

Đây là một văn bản. It is text t oo shorts.

d2w

Delete 2 words from the current cursor position

Đây là một văn bản. It is text .

Adverb – Modifier

Adverb

English

a

Around

i

Inside

Notice that above we also have i and a , but as verbs. Here i , a means another adverb. If the adverb requires verbs, then we will match the verb with the adverb and the noun to become a meaningful action.

Manipulation

Meaning

Text status

T h là một 'văn bản'. It is too short.

ciw

Change Inside Word . Change the word to include the character at the cursor position. Move to insert mode

là một 'text'. It is too short.

That

Enter text

That's a 'text'. It is too short.

Esc

Move to normal mode

Tha t is a 'text'. It is too short.

ft

Find t . Move to the letter t

That is a ' t ext'. It is too short.

skin'

Delete around ' . Delete the inner part ' and itself.

That is a. It is too short.

So here you see in Vim there are full verbs, adverbs, nouns. As well as combining words into sentences in natural language, combining verbs, adverbs, nouns with numbers on the keyboard gives us a lot, lots of actions to improve the speed of making. significant work. It is important that you learn how to "think" when working with Vim. Instead of just using a cursor, move up and down, sometimes in the unconscious …

Vim Plugin – Vim Surround

The next section will introduce the plugin. It seems you see "This game is old, like the other articles about Vim"

I actually use a lot of plugins, but here I will only introduce here the plugin I find best and adheres best to Vim's language. You can install Vim Surround according to the instructions here https://github.com/tpope/vim-surround .

With this plugin, you need to remember one more adverb, it's s – surround. Next, you just need to adhere to Vim's language.

Or imagine a simple post, that you want to change the character around your string, instead of " dill " . What do you do with it? I saw a lot of people to remove the character "then hover to position the" rest and change '. So what do you do with Vim Surround.

Pretty simple answer cs '" – Change Surround'". Change the four characters around, from ' citadel ' .

The following is a demo using Vim Surround for editing HTML files. Pretty good ? You can consult and guess which characters are used.

Conclude

According to whileimautomaton.net , there are 7 levels for 1 Vim user. The author is seeing himself in the middle of level 3 and 4 when not fully using the full strength of Text Object and depends on Visual Mode. Simply put, I still have not mastered the "Vim Language". The article is intended to share with readers a different view of Vim, what I know and look forward to helping you in learning this great editor ?

References

ITZone via Viblo

Share the news now