Linux-Vim usage tips

1: The execution result of the import command: r! Command

Is to import the current file to another folder for example (: r import location) for example (: r / tmp / xxx)

You can also use (:! Command) to use commands, for example (:! Ls)

 Use (: r! Command) to import the things obtained by the command into the current file, for example (: r! Date)

2: Define shortcut keys: map shortcut key trigger command

For example, to comment a certain line in the file, if you want to do regular operations, you need to enter 0 first to enter the beginning of the line,

Then enter i to enter edit mode, followed by #, and finally press esc to exit edit mode,

Use map to define shortcut keys: map ^ P (hold Ctrl + V + P at the same time) I (insert at the beginning of the line)

You can use (ctrl + p) to perform a shortcut operation to delete the # sign

3: Continuous line comments: n1, n2 / @ /% / g (@ indicates the character to be replaced, command,% indicates the symbol to be replaced)

                         : n1, n2s / ^ / # / g (s means a certain range of lines, ^ means the beginning of the line # means the symbol replaced with) means to add # at the beginning of the line

                         : n1, n2s / ^ # // g means to delete the # sign at the beginning of the line

                         : n1, n2s / ^ / \ / \ // g means to change # to // at the beginning of the line where \ detail is equivalent to the escape character in c language

4: Replace: ab ab means to convert a to b. The function is to use input a to be equivalent to input b

Enter, enter i to enter edit mode, enter mymail

Enter becomes [email protected]

In order to prevent the shortcut key defined by restart from being invalid, it needs to be defined in the user directory

For example, the root user needs to enter the shortcut method to be set in this file in /root/.vimrc.

Published 148 original articles · Like 10 · Visitors 20,000+

Guess you like

Origin blog.csdn.net/ab1605014317/article/details/104662610