vim short guide

vimIs anvery muchPopular file editor, especially among programmers. It is actively developed and updated frequently, and has a large community around it. There is even oneVim meeting!

viIn modern systems, this is just an alias forvim, meaning isviImProved.

You can start it by runningviOn the command line.

You can edit the specific file by specifying the file name when calling:

vi test.txt

You must know that Vim has 2 main modes:

  • command(ornormal) Mode
  • insertmode

When you start the editor, you are in command mode. You cannot enter the desired text from the GUI-based editor. You must enterInsert mode. You can pressikey. after finishing,-- INSERT --The word appears at the bottom of the editor:

Now you can start to enter the contents of the file and fill in the screen:

You can use the arrow keys to move through the file, or you can useh-j-k-lkey.h-lFor left and right,j-kFor the decline.

After editing, you can pressescKey to exit insert mode and then returnCommand mode.

At this point, you can browse the file, but you cannot add content to it (please pay attention to which key you press, as they may be commands).

One thing you might want to do now issave document. You can press:(Colon), thenw.

you couldSave and exiturgent:thenwwithq::wq

you couldExit without saving,press:thenqwith!::q!

you couldUndoAnd edit by entering command mode and pressingu. you couldRedo(Cancel undo) by pressingctrl-r.

These are the basics of using Vim. From here on is a rabbit hole, which we cannot introduce in this brief introduction.

I will only mention the commands that get you to start editing with Vim:

  • pressxKey to delete the currently highlighted character
  • urgentAAt the end of the currently selected row
  • press0Go to the beginning of the line
  • Go to the first character of the word and pressdfollowed bywDelete that word. If you followeinsteadw, Leave the space before the next word
  • Use the number betweendwithwDelete multiple words, for example usingd3wDelete 3 words forward
  • pressdfollowed bydDelete the entire line. pressdfollowed by$Delete the entire line from the cursor position until the end

To learn more about Vim, I can recommendVim faqEspecially runningvimtutorCommand, this command should already be installed in the system and will greatly help you startvimexplore.

Download mine for freeLinux Command Manual

More cli tutorials: