Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
If you are running vi: you cannot use colors. I guess your vi is linked to vim. If you are not sure, start vi without any files ($ vi <enter>), it should give you info about vim.
If you have vim, check the following dir:
/usr/share/vim/vim61/colors (the 61 could be different)
Especially the README.txt file.
The first one can be used for global settings, the second is user specific.
Something like this could do what you want (colorized highlighting based on file you are editing):
" Vim syntax support file
so /usr/share/vim/vim61/syntax/syntax.vim
" Is gui running
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Determine terminal type
let term=$TERM
if term != "linux"
" Set colors for none linux (console) term
hi Comment ctermfg=DarkBlue guifg=Blue
hi Statement ctermfg=DarkRed guifg=Brown
hi Identifier ctermfg=Blue guifg=DarkCyan
hi PreProc ctermfg=Magenta guifg=Purple
hi Constant ctermfg=Black guifg=Magenta
hi Special ctermfg=DarkMagenta guifg=SlateBlue
hi Type ctermfg=DarkCyan guifg=SeaGreen
hi Ignore ctermfg=Gray guifg=bg
endif
This will set highlighting and syntax support, which will probably enough in your case.
I did not like the default colors in my (x)term, which has a light background, so I set some of them according to my likings. Again, you might not need this, it's there to give you an idea and to 'play with'.
Check to see if the syntax support file points to the correct directory.
With : help <command> you can get some more info about the above commands.
Originally posted by druuna These two files areread when vi starts:
/etc/vimrc
and
~/.vimrc
The first one can be used for global settings, the second is user specific.
Something like this could do what you want (colorized highlighting based on file you are editing):
" Vim syntax support file
so /usr/share/vim/vim61/syntax/syntax.vim
" Is gui running
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Determine terminal type
let term=$TERM
if term != "linux"
" Set colors for none linux (console) term
hi Comment ctermfg=DarkBlue guifg=Blue
hi Statement ctermfg=DarkRed guifg=Brown
hi Identifier ctermfg=Blue guifg=DarkCyan
hi PreProc ctermfg=Magenta guifg=Purple
hi Constant ctermfg=Black guifg=Magenta
hi Special ctermfg=DarkMagenta guifg=SlateBlue
hi Type ctermfg=DarkCyan guifg=SeaGreen
hi Ignore ctermfg=Gray guifg=bg
endif
This will set highlighting and syntax support, which will probably enough in your case.
I did not like the default colors in my (x)term, which has a light background, so I set some of them according to my likings. Again, you might not need this, it's there to give you an idea and to 'play with'.
Check to see if the syntax support file points to the correct directory.
With : help <command> you can get some more info about the above commands.
good info..thanks..ive been searching on how to customize syntax highlighting.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.