: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.
Nura111Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

farzanjCommented:
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
0
Nura111Author Commented:
its just an text file with comment #
its the slow-queries-log file
0
farzanjCommented:
Get a wonderful colorscheme of your choice from here

http://vimcolorschemetest.googlecode.com/svn/html/index-c.html
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

farzanjCommented:
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
0
farzanjCommented:
Also try this:
syntax on
highlight Comment term=bold ctermfg=6 guifg=Cyan
0
Nura111Author Commented:
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  
0
Nura111Author Commented:
tried syntax on
highlight Comment term=bold ctermfg=6 guifg=Cyan
it doesnt do anything
0
farzanjCommented:
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
0
farzanjCommented:
Ok, try

:colo blue


Does this work?

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

:wq
0
Nura111Author Commented:
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
0
Nura111Author Commented:
yes its change the background to blue
0
farzanjCommented:
Ok

It is

:syntax on
:highlight Comment term=bold ctermfg=6 guifg=Cyan
0
farzanjCommented:
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.
0
Nura111Author Commented:
no not doing anything
0
Nura111Author Commented:
I cant seem to find .vimrc file
0
farzanjCommented:
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.
0
Nura111Author Commented:

se nu
0
Nura111Author Commented:
i created it in home/myname
0
farzanjCommented:
Now when you open any file, you should see something new, what is it?
0
Nura111Author Commented:
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
0
farzanjCommented:
Why are you using pico??

Why are you not doing

vim ~/.vimrc

or

gvim ~/.vimrc

pico is a totally different editor.

Use gvim
0
Nura111Author Commented:
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?
0
farzanjCommented:
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.
0
Nura111Author Commented:
its ubuntu and yes i see numbers of lines
0
farzanjCommented:
Can you install gvim?

0
Nura111Author Commented:
i installed it
0
Nura111Author Commented:
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!
0
wesly_chenCommented:
> how can I highlight the comment
> its just an text file with comment #
> its the slow-queries-log file

$ echo "syntax on" >> ~/.vimrc
$ echo 'syntax match group1 /^#.*/' >> ~/.vimrc
$ echo "highlight link group1 Comment" >> ~/.vimrc

Then use vi to open the log file....
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nura111Author Commented:
where should i write those lines please??
<
$ echo "syntax on" >> ~/.vimrc
$ echo 'syntax match group1 /^#.*/' >> ~/.vimrc
$ echo "highlight link group1 Comment" >> ~/.vimrc
>
0
farzanjCommented:
Just on the shell.  He is basically telling you to write it on the .vimrc file.
0
Nura111Author Commented:
im writing it without the $ because its no recognizing it is that ok?
0
wesly_chenCommented:
Right, no $
0
Nura111Author Commented:
yes its working thank you!  now  that changed it to all files in general right?
0
wesly_chenCommented:
Right. But only for the user have that ~/.vimrc.
0
Nura111Author Commented:
ok but if i put in home doesn't it mean that all users will have it?
0
wesly_chenCommented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.