![vim 显示语法](https://i-blog.csdnimg.cn/blog_migrate/557be1ca84c5eecf71189af6cbf50636.png)
vim 显示语法
Vim is old and popular text editor. Vim roots goes to the vi. Vim is improved version of vi. Vim has a lot of features that makes users life better. One of the most loved vim feature is syntax highlighting. Syntax highlighting makes text or code easily readable by coloring statements. For this tutorial we will use following C code. Save this file as my.c .
Vim是古老而流行的文本编辑器。 Vim根源于vi。 Vim是vi的改进版本。 Vim具有许多使用户生活更美好的功能。 最受喜爱的vim功能之一是语法突出显示。 语法突出显示使文本或代码易于通过着色语句读取。 在本教程中,我们将使用以下C代码。 将此文件另存为my.c。
#include "stdio.h"
int main(){
if(1==1)
printf("I love Poftut.com\n");
}
用Vim打开文件 (Open File With Vim)
We will open file with vim and insert code above.
我们将使用vim打开文件并在上面插入代码。
$ vim my.c
Press i to switch insert mode and paste code above
按i切换插入模式并在上面粘贴代码
![](https://i-blog.csdnimg.cn/blog_migrate/6072f3315f9d756a31df375452614c74.png)
and then save the code with Escape : w
然后使用Escape保存代码:w
()
![](https://i-blog.csdnimg.cn/blog_migrate/567d6e7a47b1e34173a5eb25568b71fc.png)
打开突出显示 (Turn On Highlighting)
We will use :syntax on
command in the vim in order to turn on or enable syntax highlighting
我们将在vim中使用:syntax on
命令以打开或启用语法高亮显示
:syntax on
![Turn On Highlighting](https://i-blog.csdnimg.cn/blog_migrate/8b12314f49814722d9f51be4a73b4119.png)
![Turn On Highlighting](https://i-blog.csdnimg.cn/blog_migrate/98afb571458bf265d2710f778d388c5c.png)
关闭突出显示(Turn Off Highlighting)
We will give following command to turn off
我们将给出以下命令关闭
:syntax off
![](https://i-blog.csdnimg.cn/blog_migrate/141d01a8d3b569059e7ad73107ef8b88.png)
![Turn Off Highlighting](https://i-blog.csdnimg.cn/blog_migrate/6b052f57e3adcbcc8036a68a51a34c65.png)
使突出显示设置持久(Make Highlighting Setting Persistent)
Highlighting setting can be made persistent by adding setting to the setting files. There is two setting files to configure vim . First one is user setting file which is active for the current user and located in the current user home directory. This setting file is preferred system wide setting file.
通过将设置添加到设置文件中,可以使突出显示设置保持不变。 有两个设置文件可配置vim。 第一个是用户设置文件,该文件对于当前用户是活动的,并且位于当前用户主目录中。 此设置文件是系统范围内的首选设置文件。
$ echo "syntax on" >> .vimrc
![Make Highlighting Setting Persistent](https://i-blog.csdnimg.cn/blog_migrate/5c73e7234a4924ce005bf3df4d21d7e7.png)
Second setting file is system wide and locate at /etc/vim/vimrc . Same setting can be added to this file. This operation requires root privileges
第二个设置文件是系统范围的文件,位于/ etc / vim / vimrc 。 可以将相同设置添加到该文件。 此操作需要root特权
$ sudo echo "syntax on" >> /etc/vim/vimrc
![Make Highlighting Setting Persistent](https://i-blog.csdnimg.cn/blog_migrate/e82edf1274dc0b9d98d99e1d8a1a82b4.png)
翻译自: https://www.poftut.com/vim-syntax-highlighting-turn-off/
vim 显示语法