Gvim 1 Installation and Basic Use
Gvim 1 Installation and Basic Use
blog.csdn.net/qq_42759162/article/details/124733389
1. Installation
GVIM download: GVIM
opens the above webpage
(may be slow), and then click the red box in the figure below to
download the installation package:
1/16
Default:
2/16
Compatibility and extension selection: Vim original version and all extensions (default), it
is best to choose this option here, otherwise the installed GVIM may not be easy to use in
Windows.
3/16
The next step is to choose the installation location, it is best to choose a location other
than the C drive.
4/16
Click to install. After the installation is complete, there should be a few more GVIM icons
on the desktop, but don’t worry about it, just drag it to the recycle bin (I personally think
it’s useless, so you can keep it if you want).
2. Basic use
5/16
It should look like this after opening (maybe your interface is slightly different from mine,
don’t panic, it’s basically the same):
Well, at this time, we can start to explain the basic usage of GVIM. Students who have
never been in contact with it may find it very strange. Unlike ordinary editors, you can
directly enter the characters you want. On the contrary, if you press a few times casually,
there may be garbled characters.
Don't panic if you encounter problems~ GVIM has three modes: command mode, edit
mode and last line mode.
The interface you are now in is called 命令模式 , in this mode is Cannot edit files directly ,
but you can enter shortcut keys to perform some operations (delete lines, copy lines, move
the cursor, paste, etc.) [this is the default mode after opening the file]. As shown in the
figure above, you can see that in the command mode, the cursor of the mouse is a small
black square.
If you want to enter text like a normal editor, you need to enter it 编辑模式 . In this mode,
you can edit the content of the file.
Entering from the command mode to the editing mode is very simple, you only need to
press the button the English input method , you can try it. i
6/16
As shown in the figure below, you can see that after entering the editing mode, the mouse
cursor becomes like a normal editor, and it is displayed under GVIM --插入-- ,
indicating that you are now in editing mode.
Of course, if you want to return to command mode from edit mode at this time, just press
a esc key.
The line shown in the figure above --插入-- is the last line, 末行模式 where commands
can be entered to operate on the file (search, replace, save, exit, undo, highlight, etc.). To
enter the last line mode, you must first be in the command mode, that is, the mouse
cursor must be a small black square. In the command mode, press : or /(表示查找) to
enter the last line mode; press esc to return to the command mode from the last line
mode.
Okay, that’s the end of the explanation of the three modes of GVIM. Let’s practice more,
and we must be proficient in these operations.
7/16
module add(
a,
b,
);
input a;
input b;
output c;
wire a;
wire b;
wire c;
assign c = a + b;
endmodule
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
This is a simple addition operation, regardless of syntax. Select my code above, copy, go
into test.v, and ctrl+v paste. If ctrl+v you can't paste it, don't worry, you can click on
the toolbar first 从剪贴板粘贴 .
8/16
(3) Command mode
Press Escape from edit mode to esc enter command mode. Here we only introduce some
commonly used operations. It is enough to use these operations to complete daily tasks.
When you want to expand other usages, you can just go to Baidu at that time.
1. Cursor movement
Order Behavior
2. Copy/cut/delete/paste operations
Order Behavior
number+yy Based on the line where the cursor is (including the current line), copy
the specified number of lines down
9/16
Order Behavior
number+dd Cut/delete the line where the cursor is located (including the current line),
delete/cut the specified line downward
In the newly created file, try these operations more, and you will be able to remember
them after a few times.
3. Undo/Redo
Order Behavior
u revoke (undo)
4. Other
Order Behavior
ctrl+p Completion command, which can complete keywords that have appeared in
your current document
ctrl+q Column selection mode. After entering this mode, you can select columns
through h, j, k, l. After column selection, you can perform operations such as
inserting and copying (you can also directly select with the mouse in command
mode, and then ctrl+q)
10/16
Search keywords: click the keyword with the mouse, then *, n to search down, N to
search up
column insert:
1. ctrl+q enters the column selection mode, hjkl (or up, down, left, and right
keys) selects the left, bottom, upper and right range (you can also directly
select the mouse in the command mode, and then ctrl+q)
2. Uppercase I edit input text
3. esc to exit
11/16
12/16
Recording command
qa,q,100@a
q start recording
a recording name
q end recording
Order Behavior
:w save document
:q exit file
13/16
Order Behavior
:wq 保存并退出文件
:q! 强制退出文件且不保存
:!外部命令 调用外部命令,当外部命令执行结束之后按下任意键回到vim编辑
器打开的内容
/关键词 搜索/查找关键词
N/n 在搜索结果中切换上(N)/下(n)一个结果
:行数 跳到指定行数或者直接在命令窗口行数加G
==别名非常好用!!!==如果你是一个Verilog开发者,可以通过起别名的方式来保存一
些Verilog模板,可以极大地提升你的编程效率!具体请参考: gvim【二】:ab命令快速制
作verilog模板
文本替换
14/16
:s/搜索的关键词/新的内容 替换光标所在行的第一处符合条件的内容
:s/搜索的关键词/新的内容/g 替换光标所在行的全部符合条件的内容
:%s/搜索的关键词/新的内容 替换整个文档中每行第一个符合条件的内容
:%s/搜索的关键词/新的内容/g 替换整个文档的符合条件的内容
1
2
3
4
%表示整个文件
g表示全局(global)
1
2
常用:
替换整个文档中的字符 :%s/xx/yy/gc
%s:作用在整个文档
xx:要被替换的字符
yy:替换为yy
gc:一个一个的进行替换,如果只有g的话就是全部替换
替换某个部分的字符
:10,15s/xx/yy/gc
10,15表示10到15行
15/16
You can use the command echo $VIM to determine the installation directory of Vim. The
user home directory can be determined using the command echo $HOME. The user
configuration file takes precedence over the system configuration file. When Vim starts, it
will read the .vimrc file in the root directory of the current user first. Therefore, the
personalized configuration related to individual users is generally placed in ~/.vimrc.
16/16