linux-vim instructions

Learning linux-4

Advanced commands of vim:

Commands in command line mode

instruction meaning
shift+6 Move the cursor to the first column of the line where the cursor is
shift+4 Move the cursor to the last column of the line where the cursor is
shift+g Move the cursor to the last line of the file
gg Move the cursor to the first line of the file
num shift+g Move the cursor to the first column of row num
shift+f Page down
shift+b Page up
shift+h Move the cursor to the first column at the beginning
shift+m Move the cursor to the first column of the middle row
shift+l Move the cursor to the first column of the last line
dd Delete the line where the cursor is
is iit Delete the num line below the cursor (delete multiple lines)
u Undo the last operation
Ctrl+r Redo once undo
yy Copy the line where the cursor is
p Paste
d line number shift+g Delete the content from the line where the cursor is to the specified line number
y line number shift+g Copy the content between the line where the cursor is located and the specified line number
r Replace the character under the cursor
cw Delete a word and enter insert mode
shift+c Delete the content from the current cursor to the end of the line and enter insert mode
cc Delete the line where the current cursor is located, and enter insert mode

The expanded content of the last line mode:

instruction meaning
set no Show line number
set nonu Cancel line number
set nohlsearch Cancel highlight
/string Full text search string character string n Move the cursor to the next
?string Full text search string character string n Move the cursor to the next
n,m $/oldstring/newstring Replace the first oldstring in each line
n,m $oldstring/newstring Full text replacement

As this part of the content is not convenient to use pictures to display one by one, it is recommended to directly practice it, and it will be more touching.

Supplement to the cat command:

instruction meaning
cat filename Show file content
cat a.c b.c > c.c Combine the contents of ac and bc into cc
cat >filename Write the content entered by the user in the terminal to the file

在这里插入图片描述
在这里插入图片描述

Part of the configuration about vim:

如果希望每次进入文件编辑时,都可以是设置好的,那么就需要在终端中输入 vim ~/.vimrc 进入当前用户的vim配置文件中,当然如果需要修改所有用户的vim配置的话,就需要在root用户下输入 vim /etc/vimrc ,就可以进入设置了。
以下是部分的配置指令:

指令 含义
set nu 显示行号
set autoindent 设置自动对齐
set smartindent 设置智能对齐
set tabstop=4 设置tab缩进四格
set shiftwidth=4 设置自动缩进四格
set mouse=a 设置鼠标有效
set showmatch 设置自动匹配
set cindent 设置c语言等结构化程序设计语言的缩进方式
syntax on 高亮显示

在这里插入图片描述

Guess you like

Origin blog.csdn.net/weixin_45137562/article/details/114458817