Installation and use of vim under ubuntu

vim installation

Ordinary user login input: sudo apt-get install vim-gtk
Root user directly input: apt-get install vim-gtk
Then wait for the download and installation, you will be asked yes or no halfway, just press y.

Let's talk about usage:

vim three modes
Command mode, input mode, bottom line mode
a and esc switch input mode and command mode

vim index
vim + index
vim +3 index
vim +/*** index Enter the index file* **Press n to switch the position of the first appearance. In

bottom line mode:
:n Cut the file backward 
:N :prev Cut the file forward
:w Write the file from the memory to the hard disk (save)
:q Quit
:! Force quit
: ls Lists all files opened by the current editor
: 15 Locate to the fifteenth line
/xxx Search backward from the cursor position for the first occurrence of
xxx? xxx Search forward from the cursor position for the first occurrence of xxx

Command mode is commonly used Command:
h cursor left
j cursor down
k cursor up
l cursor right
ctrl+f page down
ctrl+b page up
ctrl+d half page down
ctrl+u half page up
dd delete the line where the cursor is
o insert a line below the line where the cursor is and switch to input mode
yy copy the line where the
cursor is p where the cursor is Paste
P below the line Paste the

s command above the line where the cursor is located to replace the string
: s/str1/str2/ Replace the first occurrence of the string str1 on the line with the string str2

  :s/str1/str2/g Replace the string str2 with the string str2 Replace all occurrences of the string str1

  :.,$ s/str1/str2/g in the line with the string str2 Replace all occurrences of the string from the current line to the end of the text str1

  :1,$ s/str1/str2/g with the string str2 replaces all occurrences of the string str1 in the text.

You will not be used to it at first, but after two or three days you will find that it is powerful. After a month, you will find that the command window under dos is simply scum! ! ! (ps: Be sure to remember those shortcut keys, which are quite easy to use and powerful, and can save a lot of trouble)

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326892263&siteId=291194637