The second class of Linux20180417 in four weeks (April 12)

image.png


vim color display and move cursor

The same file in different directories may or may not have colors.

See the example below:

vim /etc/passwd

image.png

After copying /etc/passwd to /tmp/, there is no color

image.png

image.png

Then try adding a few lines of #comment, and the color will be there. (The first line of gg, shift o can be adjusted to the previous line of the first line and enter the editing mode)

image.png

If you change the file name to passwd.sh see

image.png

So there are many determinants of color, such as changing to .py, it will be displayed according to the rules of python

The address of the vim configuration file is /etc/vimrc


image.png

in normal mode

hjkl

left bottom top right

Space to the right number + space is to move a few positions to the right. Also the above hjkl also supports remembering the number in front


ctrl b scroll backward one screen at a time

ctrl f to scroll forward one screen at a time


Copy, cut and paste in normal mode

image.png


dd actually cuts this line 

yy is to copy this line

there's no good way,



Enter edit mode!


i enter edit mode

I (big i) enters editing at the beginning of the line where the cursor is located

o Start editing from the line below the cursor line

a (after) start editing after the character where the cursor is

A goes to end of line and is the opposite of I

image.png



Finally, enter command mode


image.png

When replacing, g means global global, replace all, otherwise it is only found in the first line. In addition, the scope must be real and effective


If the content to be replaced has /, it will conflict with the / in the command. This can be used as follows:

Replace the original / with other special symbols

:1,$s^love^pleased^g

image.png



:nohl no high light


:x save and exit like :wq

The difference is that wq will change mtime x when viewing but not operating


image.png


image.png

image.png

In fact, there is nothing to say, just practice more.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324538367&siteId=291194637