To start vi, simply type vi at the shell prompt.
To create a new file and give it a name or to load an existing file, type vi filename
vi displays the first screen of the file. If the file isn’t long enough to fill the screen, vi shows tildes (~) on the blank lines. The cursor is at the beginning of the file.
Vi is always in either command mode or input mode (also called insert mode that is also the default mode). In command mode, the letters you type are interpreted as commands. In input mode, what you type is entered in the file you’re editing.
To switch from input mode to command mode, press the ESC key. Press it a few times just to be sure. (vi just beeps when you press Esc when you’re already in command mode.)
To switch from command mode back to input mode use a or i command (described later in this section) to tell vi where to put the new text.
1. In input mode, press the Esc key to get into command mode.
2. From command mode, type:
· :q! to exit vi without saving the changes you made to the file.
· :w to save the current file without exit.
· :wq, same as :x, to save the current file and exit.
Command
|
What It Does
|
Esc
|
Returns to command mode from input mode. In command mode, vi just beeps.
|
Enter
|
Move the cursor to the beginning of the next line.
|
0 (zero)
|
Move the cursor to the beginning of the current line.
|
$
|
Move the cursor to the end of the current line.
|
j
|
Move the cursor down one line.
|
k
|
Move the cursor up one line.
|
Ctrl + b
|
page up.
|
Ctrl + f
|
page down.
|
Ctrl + l
|
Refresh the monitor.
|
G
|
go to the last line.
|
a
|
Adds text(that is, switches to input mode so that the text you type is added immediately after the cursor).
|
A
|
Adds text at the end of the current line, switching to input mode.
|
i
|
Inserts text (that is, switches to input mode so that the text you type is inserted immediately before the cursor).
|
I
|
Inserts text at the beginning of the current line, switching to input mode.
|
o
|
Inserts line.
|
r
|
Replace character in cursor.
|
R
|
(replace mode)
|
D
|
Delete line from cursor to the end of line
|
yw
|
copy
|
p
|
paste
|
u
|
Undoes the last change.
|
U
|
Undoes all changes made to the current line since you moved to it.
|
/string
|
search string down from cursor.
|
?string
|
search string up from cursor. ‘?’ or ‘n’ to re-find.
|
?
|
re-find.
|
n
|
repeat last search action.
|
N
|
repeat last search action in the opposite direction.
|
.
|
repeat last command in vi.
|
:help
|
help for vi.
|
:wq
|
write & save & quit.
|
:x
|
same to wq.
|
:q!
|
quit without save.
|
:w
|
save.
|
:w filename
|
save to other name.
|
:set number
|
show line number.
|
:set nonumber
|
not show line number.
|
:set
|
show option info.
|
:g/oldtext/s//newtext/g
|
Replaces oldtext with newtext to the whole file.
|
分享到:
相关推荐
14. `tlist` 和 `kill`:这两个命令是用于查看和结束进程的,通常在系统调试和故障排除中使用。 15. `del` 和 `move`:文件管理命令,`del`用于删除文件,`/S /Q`选项可以递归删除目录及其内容而不提示,`move`用于...
隐藏 CMD 黑窗口的脚本通常用于在运行批处理文件或其他命令行程序时,避免显示命令提示符窗口,这样可以让用户在后台执行脚本而不会干扰到其他任务。 该文件需配合BAT脚本使用,在.vbs中将路径指向BAT脚本并运行该...
如`dir /b | sort > list.txt` 会排序目录中的文件并保存到`list.txt`,然后可以使用`fc /l list.txt list_sorted.txt` 比较排序前后的差异。 3. **统计分析**:`find`命令可以计数特定字符或字符串。如`type file....
List<String> commands = Arrays.asList("cmd", "/c", "dir"); ProcessBuilder pb = new ProcessBuilder(commands); Process process = pb.start(); ``` **JavaScript调用命令行** 在JavaScript中,由于安全...
* -L [ c ] list servers [ clean output ]:列出服务器。 * -p [ 1 ] print statistics [ colon format ]:打印统计信息。 * -X [ 1 ]:禁用命令、启动脚本和环境变量。 * -? show syntax summary:显示语法摘要。 ...
##### 8. **`net pause`** - **暂停服务**: ```cmd net pause 服务名 ``` 暂停指定的服务。 ##### 9. **`net send`** - **向其他计算机发送消息**: ```cmd net send IP 文本信息 ``` 向指定IP地址的...
process->start("cmd.exe", QStringList() ); ``` 这里,`"/c"`参数告诉CMD执行完`notepad.exe`后关闭,`notepad.exe`则是我们要启动的外部程序。 接下来,我们关注如何处理子进程的输出。QProcess提供了`...
process.start("cmd.exe", QStringList() ); process.waitForFinished(); ``` 这里的`start`方法启动了CMD进程,并通过`/c`参数传递了执行"dir"命令的指令。`waitForFinished`确保我们等待命令执行完成后再继续执行...
### CMD中的重定向输出与管道操作详解 在日常的编程工作中,特别是在Windows环境下进行开发时,熟练掌握CMD命令行工具的使用技巧对于提高工作效率是非常有帮助的。本文将重点介绍CMD中的重定向输出(`>`、`>>`)...
6. `perl-Module-CoreList-2.76.02-299.el7_9.noarch.rpm`: 显示Perl核心模块的版本信息,帮助确定哪些模块已经包含在当前Perl版本中。 7. `perl-version-0.99.07-6.el7.x86_64.rpm`: 为Perl处理版本号提供支持,...
2. **事件选择**: `trace-cmd list`可以列出所有可用的内核事件,用户可以根据需求选择要追踪的事件。 3. **查看日志**: `trace-cmd report`命令将追踪数据转化为可读的报告,帮助分析系统行为。 4. **保存/加载**...
cmd.Parameters.Add(new OracleParameter("p_list", oraArray)); cmd.ExecuteNonQuery(); ``` 5. **关闭连接**: 执行完存储过程后,别忘了关闭数据库连接。 通过这种方式,C#中的自定义列表(List)可以高效地...
### 遍历CheckBoxList,获得选中项的值动态绑定CheckBoxList #### 知识点一:CheckBoxList概述及应用场景 **CheckBoxList** 是ASP.NET Web Forms中一个非常有用的控件,它允许用户选择一个或多个选项。CheckBoxList...
#### 8. **高级功能** - `tlist`:显示系统中的进程。 - `kill`:结束进程。 - `route print`:显示路由表。 这些CMD命令涵盖了从基础的文件操作到复杂的网络管理,是IT专业人员必备的技能之一。熟练掌握它们,...
在Java编程中,有时我们需要执行一些系统级别的操作,如创建目录、复制文件等,这些操作在Windows系统中可以通过命令行接口(CMD)来完成。Java提供了Runtime类和ProcessBuilder类来实现这样的功能,允许我们调用...
* firewall-cmd --zone=dmz --list-ports 这将显示 dmz zone 中所有打开的端口。 firewall-cmd 命令还可以用于添加端口到 zone,例如: * firewall-cmd --zone=dmz --add-port=8080/tcp 这将添加 8080 端口到 ...
16. `tlist -t`和`kill -F`: 分别用于列出和结束进程,通常在Support Tools中。 17. `del`和`rmdir`: 用于删除文件和目录,`-F`选项可删除只读文件,`/S`和`/Q`分别用于删除目录及其内容,且不提示确认。 18. `...
- `tlist -t`:列出系统进程(需额外安装工具)。 - `kill -F`:强制结束进程(同样需要额外安装工具)。 掌握这些CMD命令,可以帮助用户高效地进行系统管理和网络操作,尤其是在没有图形用户界面的情况下。了解...