猿问

您好,想了解一下,该怎样在linux系统下如何显示关键字颜色?

linux系统字符界面下,使用VI编辑器编译C++程序时,朋友的关键字符的颜色有很多中,我的全是白的字符
请问如何设置呢?

胡说叔叔
浏览 820回答 2
2回答

慕码人2483693

linux下设置ls命令显示文件、文件夹颜色:1. LS_COLORS用 dircolors -p 可以 看到缺省的颜色设置,包括各种颜色和“粗体”,下划线,闪烁等定义。环境变量LS_COLORS时用来设置GNU ls的--color选项中的颜色的。# Below are the color init strings for the basic file types. A color init# string consists of one or more of the following numeric codes:# Attribute codes:# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed# Text color codes:# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white# Background color codes:# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=whiteNORMAL 00 # global default, although everything should be something.FILE 00 # normal fileDIR 01;34 # directory故,要设置ls的颜色,则在SHELL的配置文件(以下是tcsh的配置文件:.tcshrc,对于bash略有不同)中添加下面一行:setenv LS_COLORS 'no=00:fi=00:di=01;33:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;35:*.cmd=01;35:*.exe=01;35:*.com=01;35:*.btm=01;35:*.bat=01;35:*.sh=01;35:*.csh=01;35:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:'即可,可以参照上面的英文自行配置。另:/etc/DIR_COLORS 文件为系统默认颜色参数配置文件如果想修改定义自己的颜色参数配置文件,请执行如下操作:1) cp /etc/DIR_COLORS $HOME/.dir_colors2) 修改中的颜色定义 $HOME/.dir_colors2. CLICOLOR# CLICOLOR是用来设置是否进行颜色的显示。CLI是Command Line Interface的缩写。setenv CLICOLOR 1# LSCOLORS是用来设置当CLICOLOR被启用后,各种文件类型的颜色setenv LSCOLORS gxfxaxdxcxegedabagacadLSCOLORS的值中每两个字母为一组,分别设置某个文件类型的文字颜色和背景颜色。LSCOLORS中一共11组颜色设置,按照先后顺序,分别对以下的文件类型进行设置:directorysymbolic linksocketpipeexecutableblock specialcharacter specialexecutable with setuid bit setexecutable with setgid bit setdirectory writable to others, with sticky bitdirectory writable to others, without sticky bitLSCOLORS中,字母代表的颜色如下:a 黑色b 红色c 绿色d 棕色e 蓝色f 洋红色g 青色h 浅灰色A 黑色粗体B 红色粗体C 绿色粗体D 棕色粗体E 蓝色粗体F 洋红色粗体G 青色粗体H 浅灰色粗体x 系统默认颜色所以,如果我们想把目录显示成红色,就可以把LSCOLORS设置为bxfxaxdxcxegedabagacad就可以了////////////////////////////////////////////LSCOLORS 的含义:LSCOLORS The value of this variable describes what color to usefor which attribute when colors are enabled withCLICOLOR. This string is a concatenation of pairs of theformat fb, where f is the foreground color and b is thebackground color.The color designators are as follows:a blackb redc greend browne bluef magentag cyanh light greyA bold black, usually shows up as dark greyB bold redC bold greenD bold brown, usually shows up as yellowE bold blueF bold magentaG bold cyanH bold light grey; looks like bright whitex default foreground or backgroundNote that the above are standard ANSI colors. The actualdisplay may differ depending on the color capabilities ofthe terminal in use.The order of the attributes are as follows:1. directory2. symbolic link3. socket4. pipe5. executable6. block special7. character special8. executable with setuid bit set9. executable with setgid bit set10. directory writable to others, with sticky bit11. directory writable to others, without stickybitThe default is “exfxcxdxbxegedabagacad”, i.e. blue fore-ground and default background for regular directories,black foreground and red background for setuid executa-bles, etc.

幕布斯7119047

首先确保安装了vim-enhanced包,然后,cat ~/.vimrc; 如果有syntax on,则显示颜色,syntax off,则不显示颜色
随时随地看视频慕课网APP
我要回答