可视化编辑器
The vi editor also named as Visual Editor is one of the oldest screen-based editor and older version of vim editor used by many Unix/Linux users. It can be used from any unix based terminal interfacing. Since, the vi editor is not as a WYSIWYG, a user doesn’t have formatting capabilities such as creating paragraphs, changing fonts, line centering, etc…
vi编辑器 也被称为Visual Editor是许多Unix / Linux用户使用的最古老的基于屏幕的编辑器之一和较旧版本的vim编辑器 。 可以从任何基于unix的终端接口使用它。 由于vi编辑器不像WYSIWYG那样,用户没有格式化功能,例如创建段落,更改字体,行居中等。
Here, in this article, I have mentioned only those vi editor commands that are standard and most useful. It states, Starting vi, moving around with vi commands, editing files with vi editing commands, and colon “:” commands:
在本文中,我仅提到了那些标准且最有用的vi编辑器命令。 它指出,启动vi,使用vi命令移动,使用vi编辑命令编辑文件,并使用冒号“ : ”命令:
Opening a file using vi editor:
使用vi编辑器打开文件:
Simply enter the following command at the terminal command line to open single or multiple files:
只需在终端命令行输入以下命令即可打开单个或多个文件:
vi myfileone myfiletwo
vi myfileone myfiletwo
where myfileone and myfiletwo are the names of the files which you want to open.
其中myfileone和myfiletwo是您要打开的文件的名称。
Moving around with the vi editor commands:
使用vi编辑器命令移动:
Moving around is one of the challenging tasks for beginners in vi editor. In order to do so, place the vi editor in command mode simply by pressing the “Esc” key. Following are the commands that can move the cursor in vi editor.
对于vi编辑器的初学者来说,四处移动是一项具有挑战性的任务。 为此,只需按“ Esc”键即可将vi编辑器置于命令模式。 以下是可以在vi编辑器中移动光标的命令。
Commands | Actions |
h or ← | Moves the cursor to left |
l or → | Moves the cursor to right |
j or ↓ | Moves the cursor down |
k or ↑ | Moves the cursor up |
^F or PageDown | Moves screen one page down |
^B or PageUp | Moves screen one page up |
^U | Moves screen half a page up. |
^D | Moves screen half a page down |
^E | Moves the screen one line down |
^Y | Moves the screen one line up |
+ | Sends to the beginning of the next line |
– | Sends to the beginning of the previous line |
0 (zero) | Sends to the beginning of the current line |
$ | Sends to the end of the current line |
} | Sends to the next blank line |
{ | Sends to the previous blank line |
[[ | Sends to the beginning of the file |
]] | Sends to the end of the file |
” | Switch you between beginning of file and current line |
b | Sends punctuation mark or one word back |
B | Sends one word back , including punctuation marks |
e | Sends to the end of the next word or punctuation mark |
E | Goes to the end of the next word, including punctuation marks |
gg | Goes to the top of the file |
G | Goes to the end of the file |
^H | Goes one character back, including newlines |
H | Goes to the top of the current page |
^P | Goes one line up |
L | Goes to the bottom of the current page |
w | Goes to the beginning of the next word or punctuation mark |
W | Goes to the beginning of the next word, including punctuation marks |
^Z | Suspends the vi; You can use the “fg” command to resume |
ZZ | Save the file and exit. |
指令 | 动作 |
h或← | 向左移动光标 |
l或→ | 向右移动光标 |
j 或 ↓ | 向下移动光标 |
k 或 ↑ | 向上移动光标 |
^ F或PageDown | 将屏幕向下移动一页 |
^ B或PageUp | 将屏幕向上移动一页 |
^ U | 将屏幕向上移动半页。 |
^ D | 将屏幕向下移动半页 |
^ E | 将屏幕向下移动一行 |
^ Y | 将屏幕向上移动一行 |
+ | 发送到下一行的开头 |
– | 发送到上一行的开头 |
0(零) | 发送到当前行的开头 |
$ | 发送到当前行的末尾 |
} | 发送到下一个空白行 |
{ | 发送到上一个空白行 |
[[ | 发送到文件的开头 |
]] | 发送到文件末尾 |
” | 在文件开头和当前行之间切换 |
b | 返回标点符号或一个单词 |
乙 | 发回一个单词,包括标点符号 |
Ë | 发送到下一个单词或标点符号的末尾 |
Ë | 转到下一个单词的末尾,包括标点符号 |
gg | 转到文件顶部 |
G | 转到文件末尾 |
^ H | 返回一个字符,包括换行符 |
H | 转到当前页面的顶部 |
^ P | 向上一行 |
大号 | 转到当前页面的底部 |
w | 转到下一个单词或标点符号的开头 |
w ^ | 转到下一个单词的开头,包括标点符号 |
^ Z | 挂起vi; 您可以使用“ fg ”命令恢复 |
Z Z | 保存文件并退出。 |
Editing files using vi editor commands:
使用vi编辑器命令编辑文件:
To edit a file in vi editor, simply place the editor into a command mode. In order to edit a file in vi, place the editor into command mode.
要在vi编辑器中编辑文件,只需将编辑器置于命令模式即可。 为了在vi中编辑文件,请将编辑器置于命令模式。
back-space | Removes the character before the cursor |
del | Removes the character mentioned under the cursor |
i | Inserts text under the cursor |
I | Inserts text under the cursor starting from the beginning of the current line |
a | Inserts text starting after current character |
A | Inserts text starting at the end of the line after the last character |
cc | Removes the whole line and moves into insert mode |
cw | Removes the current word and moves into insert mode. |
C | Deletes to the end of line and moves to insert mode. |
Y | Yank, copy current line to buffer |
dd | Removes the current line |
dw | Removes the current word |
D | Removes current line (but leave the newline) |
J | Joins the next line with the current line |
o | Inserts after the current line |
O | Inserts before the current line |
p | Pastes the lines in the buffer (from Y, dd, or x) after the current line |
P | Pastes the lines in the buffer before the current line |
rc | Overwrites with the character c, or replaces the current character |
R | Change to overwrite mode |
s | Removes the current character and moves into insert mode |
S | Removes the current line and moves into insert mode |
u | Undo the last activity |
U | Switch you between undoing and redoing the last edit |
v | Visual: starts the selection for a “d” (delete) or “Y” (yank). Simply move in the direction using movement keys after typing “v” to see the selection |
V | Visual line: selects the current line for deletion or Yank |
x | Removes the character under the cursor |
X | Removes the character after the cursor |
~ | Capitalize the current character |
== | Unindents the current line by typing the equal sign two times |
. | Repeats the last command |
F1 | Shows online help |
退格键 | 删除光标之前的字符 |
德尔 | 删除光标下方提到的字符 |
一世 | 在光标下方插入文本 |
一世 | 从当前行的开头开始在光标下方插入文本 |
一个 | 在当前字符之后插入文本 |
一个 | 在最后一个字符之后的行末插入文本 |
抄送 | 删除整行并进入插入模式 |
连续波 | 删除当前单词并进入插入模式。 |
C | 删除到行尾并进入插入模式。 |
ÿ | 拖动,将当前行复制到缓冲区 |
dd | 删除当前行 |
dw | 删除当前单词 |
d | 删除当前行(但保留换行符) |
Ĵ | 将下一行与当前行连接 |
Ø | 在当前行之后插入 |
Ø | 在当前行之前插入 |
p | 将当前行之后的行(从Y , dd或x )粘贴到缓冲区中 |
P | 将各行粘贴到当前行之前的缓冲区中 |
rc | 用字符c覆盖,或替换当前字符 |
[R | 更改为覆盖模式 |
s | 删除当前字符并进入插入模式 |
小号 | 删除当前行并进入插入模式 |
ü | 撤消上一个活动 |
ü | 在撤消和重做上一次编辑之间切换 |
v | 视觉:开始选择“ d ”(删除)或“ Y ”(猛击)。 键入“ v ”后,只需使用移动键在方向上移动即可查看选择 |
V | 可视行:选择要删除或Yank的当前行 |
X | 删除光标下的字符 |
X | 删除光标后的字符 |
〜 | 大写当前字符 |
== | 通过两次键入等号使当前行缩进 |
。 | 重复上一条命令 |
F1 | 显示在线帮助 |
Using colon “:” vi commands:
使用冒号“:” vi命令:
:w | Writes to the file; If file name is not given on the command line, it will complain |
:w file-name | Saves the file to specified filename |
:q | Quit. In vim editor, also exits from help. |
:q! | Quits without saving. |
:wq | Writes to the file and quit (same as “ZZ” command) |
:w | 写入文件; 如果在命令行上未提供文件名,它将抱怨 |
:w文件名 | 将文件保存到指定的文件名 |
:q | 退出。 在vim编辑器中,也从帮助中退出。 |
:q! | 退出而不保存。 |
:wq | 写入文件并退出(与“ ZZ ”命令相同) |
翻译自: https://www.eukhost.com/blog/webhosting/useful-vi-editor-commands-visual-editor/
可视化编辑器