Linux Vi/vim

Source: Internet
Author: User
Tags delete key save file

Linux Vi/vim

All UNIX like systems will be built into the VI document editor, and other document editors will not necessarily exist.

But at the moment we use more of the Vim editor.

Vim has the ability to edit the program, can be active in font color to identify the correctness of the grammar, convenient programming.

What is vim

Vim is a text editor developed from VI. Code completion of the compilation and error jumps and other convenient programming features are particularly rich, in the programmer is widely used.

To put it simply, VI is an old-fashioned word processor, but it has a full range of functions, but there is still room for improvement. Vim can be said to be a program developer's

It's a very handy tool.

Use of Vi/vim

Basically Vi/vim is divided into three modes, namely command mode input mode (Insert mode) and Baseline command mode (last line mode).

The three modes of action are:

Command mode:

The user has just started Vi/vim and entered command mode.

In this state, the keystrokes are recognized by VIM as commands rather than as input characters. For example, we press I at this time, and do not enter a character, but are

As a command.

Here are a few common commands:

I switch to input mode to enter characters.

X Delete the character at the current cursor location

: Switch to the bottom line command mode to enter the command at the lowest line.

If you want to edit the text: Start vim, enter command mode, press I, switch to input mode.

Command mode has only some of the most basic commands, so you still have to rely on the bottom line command mode to enter more commands.

Input mode

Press I in command mode to enter the input mode.

In input mode, you can use the buttons:

Character keys and shift combinations, enter characters

Enter enter key to break line

Back space backspace key to delete the previous character of the cursor

Del Delete key Delete cursor after one character

Arrow keys move cursor in text

Home/end move cursor to beginning/end of line

Page up/page up/down page

Insert Toggle cursor is input/replace mode, the cursor will become a vertical bar/underline

ESC launches input mode, switches to command mode

Baseline Command mode

Press: (colon) in command mode to enter the baseline command mode.

The bottom line command mode can enter commands for single or multiple characters, and there are many commands available.

In the baseline command mode, the Basic command has (the colon has been omitted)

Q Exit Program

W Save File

Press the ESC key to exit the bottom command mode at any time.

Vi/vim Key Description

In addition to the above simple example of the I ESC Wq, in fact, Vim has a very many keys can be used.

Part I: General mode available cursor movement, copy paste, search replacement, etc.

How to move the cursor

h or LEFT ARROW key to move one character to the left

J or DOWN ARROW key cursor moves down one character

K or up ARROW key to move the cursor up one character

L or RIGHT ARROW key cursor move one character to the right

If you put your right hand on the keyboard, you will find that the HJKL are arranged together, so you can use the four buttons to move the cursor, if you want to move multiple times

, such as moving down 30 lines, you can use a combination of 30j or 30

[Ctrl + [f] screen moves down one page, equivalent to page DOWN button (common)

Ctrl + b screen moves up one page, equivalent to page up

Ctrl + u screen moves up half page

+ cursor moves to the next line of non-whitespace

-Cursor moves to the previous line of non-whitespace

N<space> that n means "number" for example 20, press the number and then press SPACEBAR, the cursor moves back to the right to move the n characters of this line, for example

20<space> the cursor moves 20 characters away from the back

0 or function key [home] This is the number [0] move to the front of the line prompt (common)

$ or Function key [end] moves to the last face character of this line

Linux Vi/vim

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.