LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 08-06-2005, 01:33 AM   #1
manikantha
Member
 
Registered: Sep 2004
Location: Guntur,India
Distribution: FC3 - 64-Bit
Posts: 56

Rep: Reputation: 21
"HOWTO Change Colour of Comments in VIM editor"


Hi,
Can neone tell me how to change the colour of COMMENTS in VIM editor.
Thanx in Anticipation.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 08-06-2005, 02:22 AM   #2
oblivious69
Member
 
Registered: May 2005
Distribution: debian
Posts: 79

Rep: Reputation: 15
I think this depends on the type of file you are editing. Vim supports syntax highlighting and comes with support for a lot of languages. There are individual syntax files for each language or type of file and you can set colors in them. I suggest googling for vim and syntax color
 
Old 04-12-2009, 06:41 AM   #3
sukirti
LQ Newbie
 
Registered: Apr 2009
Posts: 2

Rep: Reputation: 6
Just type this vim command in the editor :highlight Comment ctermfg=green/blue/yellow etc.
 
3 members found this post helpful.
Old 04-15-2013, 09:36 AM   #4
rytec
Member
 
Registered: Mar 2009
Location: Belgium
Distribution: Ubuntu server 12.04 LTS / Raspbian Wheezy
Posts: 64

Rep: Reputation: 7
Is it possible when you have typed this command to keep it that way ?
When I close the vim editor, open it again, the comment color is dark Blue again and it's not good readable with a black backscreen.
 
Old 04-15-2013, 08:28 PM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
You need to edit the hidden file '.vimrc' in your home dir.
Also, there are many 'themes' you can use that have different colour combos https://code.google.com/p/vimcolorschemetest/
 
2 members found this post helpful.
Old 04-16-2013, 01:06 AM   #6
sukirti
LQ Newbie
 
Registered: Apr 2009
Posts: 2

Rep: Reputation: 6
Quote:
Originally Posted by rytec View Post
Is it possible when you have typed this command to keep it that way ?
When I close the vim editor, open it again, the comment color is dark Blue again and it's not good readable with a black backscreen.
type in the command in your local vimrc file (~/.vimrc). If no vimrc is present in your home directory, copy the global file /etc/vim/vimrc to your home directory as .vimrc and edit it.
 
1 members found this post helpful.
Old 04-16-2013, 09:18 AM   #7
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,653
Blog Entries: 2

Rep: Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095Reputation: 4095
You can find a good video tutorial about Vim colorschemes here: http://vimcasts.org/episodes/creatin...hemes-for-vim/
 
1 members found this post helpful.
Old 07-16-2013, 02:08 AM   #8
anish2good
LQ Newbie
 
Registered: Jul 2011
Posts: 15

Rep: Reputation: Disabled
vim 5 minute tutorial, learn vi/vim is to know what the letters stand for
y(ank) - copy
d(elete) - cuta
c(hange) - replace
p(aste) - put from buffer after cursor
o(pen) - start a new line
i(nsert) - insert before current character
a(ppend) - insert after current character
w(ord) - moves to beginning of next word
b(ack) - moves to beginning of current word or prior word
e(nd) - moves to end of current word or next word
f(ind) - moves to a character on the current line
movement keys you just need to learn: h,j,k,l
^ - beginning of text on a line
$ - end of text on a line
0 - first position on line

most commands can be prefaced with numeric modifiers.
2w - means move 2 words
5h - means move 5 characters to the left
3k - means move 3 lines up
3fs - means move to the 3rd letter s folling the cursor

..........................

and many more....
 
Old 07-16-2013, 04:36 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
The short answer is to have a line like ...
Code:
hi Comment    cterm=NONE   ctermfg=Black        ctermbg=NONE
... in your .vimrc

The best values to use (to the right of the = signs) depend on your terminal's capabilities and your preferences.

That will only work if you are using a language for which vim has a syntax file to enable it to identify comments.

If you want to experiment ...
  1. Some cterm values: NONE, bold, italic, underline.
  2. Some ctermfg values: Black, Blue, Brown, Cyan, Gray, Green, Magenta, Red, White, Yellow, DarkBlue, DarkCyan, DarkGreen, DarkMagenta, DarkRed, DarkYellow, LightBlue, LightGreen, LightGrey, LightMagenta, LightRed (some of these may be identical to others in your terminal).
  3. ctermbg colour choice is the same as for ctermfg.
If you want to find more, start vim without naming a file to load then:
  • Enter command :help hi for information about possible hi (highlight) strings.
  • Enter command :so $VIMRUNTIME/syntax/hitest.vim to show current highlights and their settings. The existing "comment" is in the "Syntax highlighting groups" section.
tput colors will show the number of colours the terminal can display.

In gvim, Edit -> "Color Scheme" can be used to inspect the available colour schemes.

Browsing the /usr/share/vim/vim*/colors/* files may be helpful.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fedora Core 2: Screen Resolution can not change from "800X600" to "1024X 768" suhaimi_sj Fedora - Installation 18 12-17-2009 04:29 AM
Comments request for "O'Reilly's Linux iptables Pocket Reference" carboncopy General 3 03-03-2005 10:24 PM
Here is my hardware config, any "hey stop" comments? ChromeAtari Linux - Newbie 19 09-15-2004 07:57 PM
Linux Partition Table Editor - Need to change "Hidden Sectors" value Ouch_Taser Linux - Newbie 3 02-11-2004 11:03 AM
Can you change the "title" under your name that says "member" or "newbie&qu Whitehat LQ Suggestions & Feedback 3 11-19-2003 07:32 PM


All times are GMT -5. The time now is 05:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration