ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
when programming in c with emacs, after a variable is declared, i have seen emacs highlight the variable name throughout the rest of the code.
can vim do the same thing. currently with syntax highlighting, vim highlights keywords in c (for, while, if, etc.) and types (int, float, etc.), but it does not highlight user-defined types (struct names, etc.) or variable names.
does anyone know the appropriate commands/plugins to make these highlight? thanks.
not on a brand spanking new file. but if you save it right after opening (like hello.cpp), it will syntax highlight. if you use gvim (vim-x11) there's a menu item where you can choose the language and it will syntax highlight based on the language you choose.
I looked it up, and as far as I could find out, having a file ~/.vim/colors/myColors.vim with the line below should do it, but it doesn't seem to work on my vim :-(
Changing colors in this file for i.e. "Comment" does work. Strange. If somebody knows how to make it work I would also be interested. Using vim 6.1 from debian sarge/testing package.
Code:
hi Identifier ctermfg=darkgreen cterm=none guifg=palegreen
In what sense u are asking ?? .I mean if u are confused with variables declared, then there is a way in vim editor to find quick def of that variable.So why u need diff color for variables ?? .
I've found a solution. The c.vim syntax definition file of vim 6.1 doesn't seem to define "Identifier". To solve it, download an alternative c-language definition file for vim: http://www.eandem.co.uk/mrw/vim/syntax/std_c.zip
unzip it, and copy the extracted ./syntax/c.vim to ~/.vim/syntax. Now you can use lines like this in your own colorscheme file (e.g. ~/.vim/color/mycolors.vim):
Code:
hi Identifier ctermfg=darkgreen cterm=none guifg=#cd5c5c
Activate your colorscheme ("mycolors") with the vim command:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.