Using an editor (vim / nano)

Vim editor

Vim operating mode

vi filename
输入:wq
i/a/o
ESC
命令回车结束运行
进入
命令行模式
退出
插入模式
编辑模式

Insert command

command effect
a Inserted after the character under the cursor
A Inserting the end of the cursor line
i Be inserted before the character under the cursor
I The first insert the cursor line
O New line is inserted at the cursor
O Insert a new row on the cursor

Positioning command

command effect
: Not set Set the line number
:set nonu Cancel line number
gg To the first row
G To the last line
ng To the n-th row
:n To the n-th row
command effect
$ End of the line to move
0 To start of line

Delete command

command effect
x To delete the character at the cursor location
nx After you remove n characters at the cursor
dd Delete cursor line, ndd Delete n lines
d$ Delete the current cursor position to the end of the line content
dG Delete the contents of the row cursor to the end of the file
D Delete at the cursor to the end of the line content
: N1, n2d Delete the specified range of row

To pay attention to when using the backspace and delete keys in normal mode vim editor. vim editor will usually delete key function of the command identified as x, to delete the character at the current cursor position.

Copy and Cut

command effect
yy Copy the current line
nyy Copy the following line n the current line
dd Cut the current line
ndd The current line n line hereinafter
p、P Paste or row at the current cursor line

Replacement and cancellation

command effect
r Replace the character at the cursor location
R To begin replacing characters from under the cursor, press Esc to end
in Cancel the last action

Search Search and Replace command

command effect
/string Ignore case when searching for the specified search string: set ic
n Search for the next occurrence of the specified string position
:%s/old/new/g Replace text specified string
:%s/old/new/gc Replaces the specified text string, but prompted at each occurrence,
:n1,n2s/old/new/g Alternatively all old line number between n1 and n2

Save and Exit

command effect
:w Save changes
:w new_filename Save for the specified file
:wq Save changes and exit
:ZZ Save changes and exit
:q! Quit without saving changes
:wq! Save the changes and exit the root available

Import command execution results

r !命令

Defined shortcuts

map shortcut keys trigger command
ctrl + v and ctrl + p is defined shortcuts ^ p (ctrl p)

Continuous line comments

:n1,n2s/^/#/g  (行首添加 #)
:n1,n2s/^/\/\//#/g

Profiles

/home/username/.vimrc
/root/.vimrc

nano editor

The caret (^) indicates whether the Ctrl key.

nano control commands:

command description
Ctrl + C And then displays the cursor position in the text editing buffer
Ctrl + G The main display window nano's help
Ctrl + J Adjust the current text of paragraphs
Ctrl + K 剪切文本行,并将其保存在剪切缓冲区
Ctrl + O 将当前文本编辑缓冲区的内容写入文件
Ctrl + R 将文件读入当前文本编辑缓冲区
Ctrl + T 启动可用的拼写检查器
Ctrl + U 将剪切缓冲区中的内容放入当前行
Ctrl + V 翻动文本编辑缓冲区中的下一页内容
Ctrl + W 在文本编辑缓冲区中搜索单词或短语
Ctrl + X 关闭当前文本编辑缓冲区,退出nano,返回shell
Ctrl + Y 翻动到文本编辑缓冲区中的上一页内容

emacs 编辑器

KWrite 编辑器

Kate 编辑器

GNOME 编辑器

发布了247 篇原创文章 · 获赞 38 · 访问量 4万+

Guess you like

Origin blog.csdn.net/weixin_39541632/article/details/104749419