Linux--how to configure vim to display the number of lines in a file and how to quickly locate it

Table of contents

1. Cause of the problem

2. Specific solutions for line number display

1. Temporary display

2. Permanent display

3. Quick positioning

1. Quickly locate the beginning of a line, the end of a line, or a specific line

2. Quickly locate one of our keywords

1. Cause of the problem

When we install a software environment, we often need to modify the configuration file. This requires directly finding a specific line or based on a specific keyword to quickly locate the file location. At this time, how do we configure our file display? What about the display line?

2. Specific solutions for line number display

1. Temporary display

        Temporary display (will only take effect in this operation, that is, it will not be displayed by default after we reopen the file), specific operation. First, control our input mode to our command line mode, that is, when starting the vim editor, it is opened in command mode by default . In this mode, pressed keys are translated into commands and no characters appear on the screen. If you don’t understand here, come to our direct link: vim link

        After coming to our command line, we directly: shift + : and then enter set no or set number

implement:

 show:

 The corresponding temporary cancellation display:

2. Permanent display

If we want to display it permanently, we need to modify our vim configuration file.

(1) Use the find command to find the path to the vimrc configuration file

 (2) Edit vim’s configuration file

 (3) Verification

 

3. Quick positioning

1. Quickly locate the beginning of a line, the end of a line, or a specific line

The number 0 or then | In command mode, move to the beginning of our line
$ In command mode, move to the end of our line
gg In command mode, click gg twice in succession to quickly locate the first line of our file content.
GG In command mode, click GG twice in succession to quickly locate the last line of our file content. This is often used in our append situations, such as when configuring environment variables.
ngg, nG,, or: specific line number In command mode, enter the specific number of lines + G to quickly locate a specific line of ours

 Demonstrate the last command: enter ngg or nG, n represents the line number, and the cursor will jump to the nth line of the file, for example: 60gg or 300G, and the cursor will jump according to the line number.

 Or is it:

2. Quickly locate one of our keywords

Order operate
/\<word\> Search whole word
n Search for next occurrence
N Search for the last occurrence

 

Guess you like

Origin blog.csdn.net/qq_57492774/article/details/132169623