Is there some kind of model behind many VIM teams?

I need to add a VIM identity to the IDE. I have never used VIM more than the most basic changes, and now I am stunned by the complexity of the command structure.

Is there any general structure for a combination of counter moves and insert / delete commands? I just don't see a tree for trees.

+6
vim editor
source share
4 answers

Well, obviously, for h , j , k , l , apparently, there is a finger position pattern.

The fact that ^ goes to the beginning of a line and $ goes to the end has a pattern with common regex syntax.

Ctrl-F and Ctrl-B back and forth, and it's pretty intuitive.

i inserts (before) and a are added (after the cursor). Similar,
i inserts at the beginning of the line, and a is added at the very end.

> and < indent and outdent respectively. This is also kind of intuitive.

But in general, many other commands are on all the remaining keys - it is difficult to find an intuitive mapping between the letters of the alphabet and the editor's commands.

Repeated counts are always entered before the team and basically repeat this command many times, but in some cases do something clever, but similar.

I think the secret to not being embarrassed about vi is to start with a small team. I have many colleagues who know nothing but

  • move the cursor with the arrow keys (you do not need to use h , j , k , l );
  • paste with i , delete with Del (you don't need to use x );
  • delete row with d d
  • exit input mode with Esc
  • exit vi with : x (exit) or q! (close and discard my changes!)

Since I am much smarter, the additional commands that I know and use are as follows:

  • go to the top of the file with g g , below g .
    I can go to the specified line number with (line number) g .
  • copy the string with y (yank), paste it with p
  • change the word with c w , the rest of the line with c
  • delete the word with d w , the rest of the line with d
  • I sometimes use it . to repeat the last command or u (cancel) if I messed up.

When you can use other commands, you can teach them yourself as needed.

+17
source share

This is a good article to explain the philosophy of VIM.

+10
source share

I think the characteristic that defines VIM better with respect to other editors is its wide array of motion commands. The first thing to learn in order to fully use VIM is to hit the arrow keys as little as possible, and think about the text in terms of “blocks”, such as “sentence”, “tag”, “word”, “group of brackets”.

Say that you have function foo($bar, $fooz) , you can change the parameters by simply placing the cursor anywhere in the brackets and pressing ci) (mnemonics: change the internal bracket). The same pattern applies to other commands: yank ( y ), delete ( d ), etc.

I know that this does not explain the whole “VIM philosophy”, but the combination of normal mode commands with a huge number of motion modifiers is what really made me see the light.

+2
source share

There are many pleasant and interesting lessons. One example is

http://blog.interlinked.org/tutorials/vim_tutorial.html

But the broad structure that most of you will give you is

  • There are two main editing modes: command mode and insert mode. You can switch from insert mode to command mode using the key.
  • You can execute commands in command mode by entering a single key or key sequence.
  • Teams can help you achieve a variety of goals: delete lines - dd yanking (copy lines) - yy insert lines below the current line - p insert lines above the current line - P (etc.)

    Most commands in command mode can be pre-set with a “counter” to indicate the number of times a command should be executed. For example, 3dd will delete three lines.

    One set of commands in command mode allows you to switch to insert mode. This is explained below.

  • There are various ways to enter insert mode from command mode. Among them are (i-insert at the cursor, I-insert at the beginning of the line, o-insert the line below, O-insert the line above, a-append, A-append at the end of the line.

Quick link to

http://www.andy-roberts.net/misc/vim/vim.pdf

Helps you understand the relevance of "count"

0
source share

All Articles