LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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

Reply
 
Search this Thread
Old 09-21-2004, 01:34 PM   #1
prell
Member
 
Registered: Jul 2004
Posts: 73

Rep: Reputation: 15
vim: rich ("gui") colorschemes in a terminal emulator?


I downloaded a bunch of nice colorschemes from http://www.vi-improved.org/, only to be crestfallen when they would not display as nice in the terminal as they did in gvim. Is there any terminal emulator capable of displaying these color schemes? I've tried xterm, rxvt, aterm, konsole and gnome-terminal with no luck.
 
Old 09-22-2004, 06:31 AM   #2
DaneM
Member
 
Registered: Oct 2003
Location: Chico, CA, USA
Distribution: Linux Mint
Posts: 727

Rep: Reputation: 75
Hi, prell.

Look in your home directory for a file called ".vimrc". (Try typing "ls -a ~/.vimrc".) If it's there, just add:

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif

This will tell VIM to use colors to highlight your commands and other stuff as you type/read.

If you don't have a .vimrc file, make one and add those lines. You may want to look in /usr/share/vim/vim63 for a file called, "vimrc_example.vim". If you find it, just copy it to ".vimrc" in your home directory. (Try typing "cp /usr/share/vim/vim63/vimrc_example.vim ~/.vimrc".)

I hope this helps.

--Dane
 
Old 09-22-2004, 08:59 AM   #3
prell
Member
 
Registered: Jul 2004
Posts: 73

Original Poster
Rep: Reputation: 15
Oh, I guess I should have been more explicit: colors will display, but the colors (and possibly capabilities) of gvim seem to eclipse those available on the terminals I've tried.

If you try to load this scheme (aqua) in the terminal, and then again in gvim, you'll notice what I mean. I'm assuming that vim is capable of displaying everything on the terminal that it can in gvim, but it is being held back by the capabilities of the terminal. Then again, I don't really know how canonical (and incompatible with gvim-style coloring) the method for displaying colors in linux terminals is. I looked around for a "high color" or 24-bit color-capable terminal for Linux, and didn't find anything. Any leads?

Thank you for the friendly response
 
Old 09-22-2004, 01:11 PM   #4
DaneM
Member
 
Registered: Oct 2003
Location: Chico, CA, USA
Distribution: Linux Mint
Posts: 727

Rep: Reputation: 75
Aaah, that makes more sense. :-)

That link was broken, but I think I found some other examples at http://www-2.cs.cmu.edu/~maverick/Vi...ndex-perl.html ... and they DO look nice!

I get the impression that they don't require anything more complex than 256 colors, or maybe 16-bit. Unfortunately I don't know how to get these working! I'll to some fiddling and get back to you if I can find an answer.

--Dane
 
Old 09-22-2004, 01:48 PM   #5
DaneM
Member
 
Registered: Oct 2003
Location: Chico, CA, USA
Distribution: Linux Mint
Posts: 727

Rep: Reputation: 75
Eurika!

I've found a solution (at least on my computer).

Put all your color schemes into a directory called, "~/.vimrc/colors".

Next, make a file called, "~/.vimrc/plugin/colorswitch.vim". Copy and paste the following into it:

Code:
      let SwitchSchemesFiles = globpath("$VIMRUNTIME,$HOME/.vim","colors/*.vim")
      let SwitchSchemesIndex = 0
      function! SwitchSchemes()
              let sep="\n"
              if g:SwitchSchemesIndex == -1
                      let g:SwitchSchemesIndex=0
              endif
              exe "source " . NextElement(g:SwitchSchemesFiles, sep, g:SwitchSchemesIndex)
             let g:SwitchSchemesIndex = NextIndex(g:SwitchSchemesFiles, sep, g:SwitchSchemesIndex + 1)
     endfunction
     <f12>  :call SwitchSchemes()<CR>
( from http://vim.sourceforge.net/tips/tip.php?tip_id=341 )

This will set your color scheme directory to "~/.vim/colors" and map F12 to a function that will allow you to cycle through your color schemes while in VIM.

In order for this script to work, you'll also need to download http://www.vim.org/scripts/download_...php?src_id=243 and put into the same directory with the other script.

Once you've found one that you really like, you can make it permanent by putting it at the bottom of a file called, "~/.vimrc" like so:

Code:
:colors schemename
For example, if you want to use one called "hhazure", you would insert a line that says, ":colors hhazure" into "~/.vimrc".

If you decide you want to switch colors to a specific scheme while in VIM, just press ESC and type, ":colors schemename". To return to the default scheme, type ":colors default".

I hope this works for you as well as it did for me.

--Dane

Last edited by DaneM; 09-22-2004 at 01:51 PM.
 
Old 09-22-2004, 02:05 PM   #6
prell
Member
 
Registered: Jul 2004
Posts: 73

Original Poster
Rep: Reputation: 15
It's a neat script and thank you for such involved help, but it does not solve my problem

When I do ":colorscheme aqua" in vim (in a terminal emulator), the colors change but it does not look like the aqua colorscheme at all. Like you said, I'm sure this is a matter of color depth, and I hope that vim doesn't have a problem with the color values (it doesn't seem to, since it doesn't give me any errors).

So, I'm looking for a terminal emulator that can display colors in such a way that the colorschemes will appear as expected (as in gvim). It seems to me that such a terminal emulator should exist, but the ostensibly hard-coded inclusion of only 16 colors in gnome-terminal's profile dialog is discouraging. I hope such sensibilities are not so ingrained and embedded that no such terminal emulator exists. I was looking around for an OpenGL-based terminal emulator, but didn't come up with any results.

Thanks again! Any ideas?
 
Old 09-22-2004, 03:25 PM   #7
DaneM
Member
 
Registered: Oct 2003
Location: Chico, CA, USA
Distribution: Linux Mint
Posts: 727

Rep: Reputation: 75
hmmm...

I did some comparison between the appearance in gvim and vim using these color schemes and I see what you mean about the terminal version not looking as good. I also looked around a bit on the internet for some info on whether it's possible to change the background in the terminal version to how it is in the gvim version and it would seem, unfortunately, that the only options for the background color are "light" and "dark". ( http://www.vim.org/tips/tip.php?tip_id=53 , among others ) There might be a way that I've overlooked, so don't hesitate to do some more searching if you want to.
As far as suggestions, all I can think of is that you might want to use a different scheme in the terminal than you use in gvim, so that both will look OK. I've come across a few schemes that look pretty sweet in the terminal: blackbeauty, borland, coloror, dante, delek, denim, fog, hhdblue, golden, hhdred, ibmedit, less, lingodirector, maxome, nightwish, papayawhip, ps_color, redblack, relaxedgreen, sean, xemacs, zenburn.

I've noticed that some of these schemes have lines in them referencing the terminal version of VIM specifically, like:

hi Normal term=NONE cterm=none ctermfg=gray ctermbg=DarkBLue

The "DarkBlue" bit sets the background color in ibmedit to blue in the terminal. I tried entering the gui values as cterm values in this manner in aqua.vim and it just gave me some errors, so I guess it's up to you to hack them.

Good luck!

--Dane

Last edited by DaneM; 09-22-2004 at 03:27 PM.
 
Old 09-23-2004, 09:48 AM   #8
prell
Member
 
Registered: Jul 2004
Posts: 73

Original Poster
Rep: Reputation: 15
You were able to load zenburn in a terminal? I'm guessing that was a mistake because I couldn't do it, and the colors are all defined to be "gui" colors.

Anyway, yeah it looks like the gui and terminal colors are separate issues, and that the terminal colorschemes are only using sixteen colors. It's something I suppose I have to live with for now, so no biggie I guess. I really appreciate your help and collaboration in this, so thank you! I'm sure you're as interested in it as I am
 
Old 09-23-2004, 05:44 PM   #9
DaneM
Member
 
Registered: Oct 2003
Location: Chico, CA, USA
Distribution: Linux Mint
Posts: 727

Rep: Reputation: 75
Glad to be of service. I'm sure that they'll eventually figure out how to make all those cool GUI color schemes work under the terminal.

Have a good one.

--Dane
 
Old 09-24-2004, 11:13 AM   #10
prell
Member
 
Registered: Jul 2004
Posts: 73

Original Poster
Rep: Reputation: 15
I was messing around with gvim, which at first I balked at, but once I adjusted my .gvimrc, I was able to come up with something I can definitely live with. Check out the before and after:

Before:
http://bluebeard.org/personal/files/gvim_cluttered.png

I thought it was pretty goofy to have a toolbar and a menu which not only duplicated the functionality of vim whilst eliminating the convenience of using the keyboard, but also duplicated the functionality of each other. I also thought it was goofy to have a scrollbar, for much the same reasons. So, I updated my .gvimrc thusly:

Code:
set ignorecase

set guioptions-=r  " no scrollbar on the right

set guioptions-=m  " no menu
set guioptions-=T  " no toolbar

syntax on

colorscheme desert
And this is the result:

http://bluebeard.org/personal/files/gvim_minimal.png

Pretty hot, no? My only problem so far is that I'm used to just cd-ing to a directory and doing "vi file.txt" and going from there. In gvim, I have to specify the full pathname of every file. My current workaround is to open up a terminal and do gvim&. But even as I'm typing this I ran across these tips: Tip #64: Always set your working directory to the file you're editing; Tip #2: easy edit of files in the same directory.

Alright, take it easy!

Last edited by prell; 09-24-2004 at 11:18 AM.
 
Old 09-25-2004, 09:32 PM   #11
DaneM
Member
 
Registered: Oct 2003
Location: Chico, CA, USA
Distribution: Linux Mint
Posts: 727

Rep: Reputation: 75
VERY NICE! I'll have to make use of those tweaks! Also, you can still open files directly from the command prompt using gvim: "gvim file.txt &". This will open the file in a gvim window and then give you back the terminal.

It's always cool when you can learn something while trying to answer somebody else's question :-)

Have a good one.

--Dane
 
Old 01-20-2006, 03:48 PM   #12
BigBadPenguin
Member
 
Registered: Jun 2003
Location: Warwick (.ac.uk)
Distribution: Arch, Slackware 9.0, (knoppix standing by)
Posts: 256

Rep: Reputation: 30
I realise this is perhaps a little late, but just wanted to say thanks for the tips, and add some input:

1. You can use the :cd command inside vim or gvim to set the working directory,
and (if you're working on lots of code in the same dir) then you don't have
to worry about it anymore.

2. I solved the ugly colours issue (I'm pretty sure vim will only ever use the 16
colors the terminal provides) by using gnome-terminal and just making the
terminal's colours nicer. I realise you're windowmaker user though, and my
baulk at that idea. Still, my terminal sessions are a lot prettier now.

Anyway.. I'm definitely going to clean up my gvim now, thanks for the tips!
 
Old 01-20-2006, 06:47 PM   #13
DaneM
Member
 
Registered: Oct 2003
Location: Chico, CA, USA
Distribution: Linux Mint
Posts: 727

Rep: Reputation: 75
No problem, BBP. In my humble opinion, there's no shame in reviving an old thread. Glad we could help.

--Dane
 
Old 09-10-2008, 10:07 AM   #14
piotao
LQ Newbie
 
Registered: Oct 2003
Posts: 2

Rep: Reputation: 0
hi, maybe this is far too late to answer, but I accidentally found this topic by google and I can suggest to use the mrxvt terminal application. It can display at least 256 colors. Also, there should be xterm-color on popular linux systems so it can get 256 colors also.

Then vim setting: you can set ctermfg and ctermbg to any color, just by giving the color number. For example:

:hi LineNr ctermfg=240 (should be dim gray)

The only thing is to use a proper terminal application and properly configured. For instance, using screen inside my 256-color xterm causes significant color reduction to the good old 16 colors... But this is caused by screen entirely (or its environment settings) because in pure color-term everything works like a charm!

Have fun, I hope this helps a bit
 
  


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"HOWTO Change Colour of Comments in VIM editor" manikantha Linux - General 8 07-16-2013 03:36 AM
how to set "wrapping size" in VIM staul Linux - Software 1 04-17-2005 07:39 AM
help with "post install" of vim in lfs 6.0 JusCrzn Linux From Scratch 2 12-13-2004 11:24 PM
Terminal command for GUI command "Remove to trash" GunSkit Linux - General 3 06-29-2004 01:50 PM
"segmentation error" when issuing "useradd" command through terminal with RH 9.0 kaihuang Linux - General 0 10-21-2003 11:47 PM


All times are GMT -5. The time now is 03:25 AM.

Main Menu
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