Link to home
Start Free TrialLog in
Avatar of Nura111
Nura111

asked on

:highlight Comment in Vim Editor

Hi, how can I highlight the comment. I tried by using  syntax on.
its was highlights before and i guess i did something to disable that and im not really sure what. Thank you.
Avatar of farzanj
farzanj
Flag of Canada image

Get a good color scheme.  It would do it for you.

Actually, the definition of comment is different for different languages.

For example for C-language, you can do something like

highlight cComment ctermfg=Green guifg=Green
Avatar of Nura111
Nura111

ASKER

its just an text file with comment #
its the slow-queries-log file
Get a wonderful colorscheme of your choice from here

http://vimcolorschemetest.googlecode.com/svn/html/index-c.html
Ok, then a Perl like colorscheme or shell kind of colorscheme would be suitable for you
http://vimcolorschemetest.googlecode.com/svn/html/index-pl.html
Also try this:
syntax on
highlight Comment term=bold ctermfg=6 guifg=Cyan
Avatar of Nura111

ASKER

Im not really sure what am i suppose to do with that (Im pretty new to vim and linux)
the file that i want to change the highlights is a log-queries-file its a file that mysql is generate no me. I dont want to add there things i was thinking more of changing it through the command line  
Avatar of Nura111

ASKER

tried syntax on
highlight Comment term=bold ctermfg=6 guifg=Cyan
it doesnt do anything
Are you in Linux/Unix?

DO NOT touch any files.

Your personal file for vim is

~/.vimrc

That is .vimrc file in your home directory (Linux/Unix)

In this file you can put these lines

For a temporary change, you can put these lines in the command mode--downside of course it would go away when you exit the editor

But just to test you can do

:set syntax on
:set highlight Comment term=bold ctermfg=6 guifg=Cyan
Ok, try

:colo blue


Does this work?

This is to be done in the command mode just like you write

:wq
Avatar of Nura111

ASKER

its does highlights text in other files and it did highlights for this one but from some reason its not now.

and when im trying to add  it to the command mode it say E518: Unknown option: on
 
and yes i have linux
Avatar of Nura111

ASKER

yes its change the background to blue
Ok

It is

:syntax on
:highlight Comment term=bold ctermfg=6 guifg=Cyan
Ok,

Write these lines in your .vimrc file in your home directory.

Files should have an extension name like .pl or .sh

Linux doesn't care but Vim recognizes files this way.
Avatar of Nura111

ASKER

no not doing anything
Avatar of Nura111

ASKER

I cant seem to find .vimrc file
Create it.

Just create a file

~/.vimrc

And type in it

se nu

Save and exit

Then open a file in it and tell me what you see.
Avatar of Nura111

ASKER


se nu
Avatar of Nura111

ASKER

i created it in home/myname
Now when you open any file, you should see something new, what is it?
Avatar of Nura111

ASKER

when im opening the file the only thing there is what i wrote: se nu
this is how i opened it:
pico ~/.vimrc
and i wrote inside se nu and saved it with ct X
Why are you using pico??

Why are you not doing

vim ~/.vimrc

or

gvim ~/.vimrc

pico is a totally different editor.

Use gvim
Avatar of Nura111

ASKER

im sorry!! im really really new at this

so it doent know gvim i
so i opened with vim ~/.vimrc
its already have there at first line se nu i saved and ouit and now what?
What kind of Linux is it?

If you open any other file, do you see any line numbers at all?

I am suspecting you don't have a fully installed version.  Install gvim also.  That is much better if you want life to be colorful.
Avatar of Nura111

ASKER

its ubuntu and yes i see numbers of lines
Can you install gvim?

Avatar of Nura111

ASKER

i installed it
Avatar of Nura111

ASKER

but i dont think i did it right becaus eit tell me:

You must choose one to install.
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 10 not upgraded.
Need to get 0B of archives. After unpacking 0B will be used.

i tried to install it as follows:
sudo aptitude update
sudo aptitude install gvim
gvim.


as i mentioned im pretty new isnt there is anyway for now just to change the specific files i need throw the command ?

Thank you for the help!
ASKER CERTIFIED SOLUTION
Avatar of wesly_chen
wesly_chen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nura111

ASKER

where should i write those lines please??
<
$ echo "syntax on" >> ~/.vimrc
$ echo 'syntax match group1 /^#.*/' >> ~/.vimrc
$ echo "highlight link group1 Comment" >> ~/.vimrc
>
Just on the shell.  He is basically telling you to write it on the .vimrc file.
Avatar of Nura111

ASKER

im writing it without the $ because its no recognizing it is that ok?
Right, no $
Avatar of Nura111

ASKER

yes its working thank you!  now  that changed it to all files in general right?
Right. But only for the user have that ~/.vimrc.
Avatar of Nura111

ASKER

ok but if i put in home doesn't it mean that all users will have it?
No, only for that user.
But you can do it for globally by changing /etc/vimrc  (not recommended)

Issue the two commands:

sudo  echo 'syntax match group1 /^#.*/' >> /etc/vimrc
sudo echo "highlight link group1 Comment" >> /etc/vimrc