You are not logged in.

#1 2012-03-27 00:32:33

Midnith
Member
Registered: 2012-03-27
Posts: 7

[SOLVED] Vim color scheme

Hello! This is my first post and I'm new with Archlinux, sorry if this trouble is very simple but I'm a newbie...

The question... Vim color scheme only works fine when I use sudo or when I'm root...
I've put the color scheme in /usr/share/vim/vim73/colors and in ~/.vim/colors, and I've configured /etc/vimrc and ~/.vimrc

I don't know what's wrong...

Correct color scheme (with sudo):
snapshot1x.png

Wrong color scheme (normal user):
snapshot2w.png


Thank you very much!!

Last edited by Midnith (2012-03-27 11:58:48)

Offline

#2 2012-03-27 00:57:14

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: [SOLVED] Vim color scheme

Midnith wrote:

Hello! This is my first post and I'm new with Archlinux, sorry if this trouble is very simple but I'm a newbie...

The question... Vim color scheme only works fine when I use sudo or when I'm root...
I've put the color scheme in /usr/share/vim/vim73/colors and in ~/.vim/colors, and I've configured /etc/vimrc and ~/.vimrc

I don't know what's wrong...

Correct color scheme (with sudo):
http://img838.imageshack.us/img838/7463/snapshot1x.png

Wrong color scheme (normal user):
http://img839.imageshack.us/img839/3189/snapshot2w.png


Thank you very much!!

Hi Midnith, welcome to the forum. Good job getting the images the right size smile.

If your colour scheme appears in /usr/share/vim/vim73/colors, you shouldn't need it in your user's .vim directory - you only need to set the colour in your .vimrc to the correct name.

Could you please post your ~/.vimrc? And where did you get the colour scheme?

Edit: also, have you tried other colours? And what is your terminal?

Last edited by /dev/zero (2012-03-27 00:58:32)

Offline

#3 2012-03-27 03:40:24

pshevtsov
Member
From: Novosibirsk, Russia
Registered: 2011-01-20
Posts: 52

Re: [SOLVED] Vim color scheme

Hello Midnith!

I suggest you to start vim as root (sudo) and get the current color scheme with the help of the :colorscheme command without any parameters in vim.

Then start vim as normal user and try to set color scheme from root's vim:

:colorscheme <your_color_scheme>

where <your_color_scheme> is the name of the scheme you got from root's vim.

If this helps you can make it permanent by adding colorscheme <your_color_scheme> to ~/.vimrc

Hope that helps.

Offline

#4 2012-03-27 10:01:23

Midnith
Member
Registered: 2012-03-27
Posts: 7

Re: [SOLVED] Vim color scheme

Hello again! Thanks for replying!

/dev/zero wrote:

Could you please post your ~/.vimrc? And where did you get the colour scheme?

Edit: also, have you tried other colours? And what is your terminal?

· This is mi ~/.vimrc (and also my /etc/vimrc):

set cindent
set hlsearch
set ic
set incsearch
set number
syntax on
colorscheme gummybears

· I get my color scheme from here and I modified it to get off italics.

· I tried the default colors from vim and seems that are working fine. I realized that, whem I'm with sudo (or root), change to one default color and go back to gummybears, gummybears works wrong, as in normal user.

· I'm using the konsole from kde (bash).

pshevtsov wrote:

Hello Midnith!

I suggest you to start vim as root (sudo) and get the current color scheme with the help of the :colorscheme command without any parameters in vim.

Then start vim as normal user and try to set color scheme from root's vim:

:colorscheme <your_color_scheme>

where <your_color_scheme> is the name of the scheme you got from root's vim.

If this helps you can make it permanent by adding colorscheme <your_color_scheme> to ~/.vimrc

Hope that helps.

Sorry, didn't work sad

----------------------

Thank you for helping me! smile

Offline

#5 2012-03-27 10:14:03

Earnestly
Member
Registered: 2011-08-18
Posts: 805

Re: [SOLVED] Vim color scheme

See if adding t_Co=256 to your vimrc before setting the colorscheme helps. (E.g.

set cindent
set hlsearch
set ic
set incsearch
set number
syntax on
t_Co=256
colorscheme gummybears

)

Also post the output from the following:

echo $TERM
#and
tput colors

edit: Also mention which terminal emulator you're using, xterm, (u)rxvt, etc. Thanks Karol, didn't catch it. (Konsole)
edit2: Not sure if this matters, but did you install gvim or vim?

Last edited by Earnestly (2012-03-27 10:28:06)

Offline

#6 2012-03-27 10:16:44

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: [SOLVED] Vim color scheme

sed -i 's|scheme||' ~/.vimrc

Offline

#7 2012-03-27 10:19:50

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Vim color scheme

Kaustic wrote:

edit: Also mention which terminal emulator you're using, xterm, (u)rxvt, etc.

I think he uses Konsole, as he said in the previous post.

Offline

#8 2012-03-27 10:49:38

Midnith
Member
Registered: 2012-03-27
Posts: 7

Re: [SOLVED] Vim color scheme

Hi!

Kaustic wrote:

See if adding t_Co=256 to your vimrc before setting the colorscheme helps.

This gives me this output:

Error detected while processing /home/midnith/.vimrc:
line    8:
E14: Invalid address
Press ENTER or type command to continue
Kaustic wrote:

Also post the output from the following:

echo $TERM: xterm
tput colors: 8

Kaustic wrote:

edit2: Not sure if this matters, but did you install gvim or vim?

I had got installed gvim, but with the problem, I tried to remove it and install vim, with any successfull results.

/dev/zero wrote:
sed -i 's|scheme||' ~/.vimrc

What should it do? Doesn't happen anything. sad

-----------------------------

Thank you again!

Offline

#9 2012-03-27 10:53:29

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Vim color scheme

Midnith wrote:
/dev/zero wrote:
sed -i 's|scheme||' ~/.vimrc

What should it do? Doesn't happen anything. sad

It should remove the 'scheme' part of the word 'colorscheme'. Is your vim working now?


Edit:
I think you should add 'set t_Co=256' not just 't_Co=256'. Can you please try it?

Last edited by karol (2012-03-27 10:56:06)

Offline

#10 2012-03-27 11:07:01

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: [SOLVED] Vim color scheme

Midnith wrote:
/dev/zero wrote:
sed -i 's|scheme||' ~/.vimrc

What should it do? Doesn't happen anything. sad

Karol got it. You might want to look up a tutorial on sed wink. You're lucky I didn't just give you a patch file to try and figure out big_smile.

I created a test user and gave them only your vimrc and the gummybear colour file. I sued in and tried vim. As you said, no colours. I changed "colorscheme" to "color" in your vimrc and then tried vim again. Now the colours worked.

Offline

#11 2012-03-27 11:11:03

Midnith
Member
Registered: 2012-03-27
Posts: 7

Re: [SOLVED] Vim color scheme

Hi,

karol wrote:

It should remove the 'scheme' part of the word 'colorscheme'. Is your vim working now?

Edit:
I think you should add 'set t_Co=256' not just 't_Co=256'. Can you please try it?

··· No, with only color instead of colorscheme still same sad

··· yes, you're right, is

set t_Co=256

But doesn't solve it. Now with normal user the view is this:

snapshot3a.png

But the correct view is this other:

snapshot1x.png


Thank you! smile

Offline

#12 2012-03-27 11:18:14

Earnestly
Member
Registered: 2011-08-18
Posts: 805

Re: [SOLVED] Vim color scheme

Midnith wrote:

echo $TERM: xterm
tput colors: 8

There's your problem. xterm (as indicated by tput) only supports 8 colours.

If you're using Konsole, check the configuration and change the session to xterm-256color. Alternatively can set the environment variable within your ~/.bashrc file like so: export TERM=xterm-256color

(PS: To list all the terminals you can use with 256 colours try the following command: (Iirc there was a cleaner way to do this, but alas)

ls /usr/share/terminfo/*/* | grep 256

However, you should have xterm-256color by default.)

edit: Oh and sorry about earlier, I did mean "set t_Co=256" and not just "t_Co=256".

Last edited by Earnestly (2012-03-27 11:31:12)

Offline

#13 2012-03-27 11:30:58

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,094

Re: [SOLVED] Vim color scheme

I would also suggest changing the theme itself to only use colour >15, then it will stay consistent across terminals with different settings (since almost no one ever changes the colours <15)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#14 2012-03-27 11:52:06

Midnith
Member
Registered: 2012-03-27
Posts: 7

Re: [SOLVED] Vim color scheme

Hi again!

Kaustic wrote:

There's your problem. xterm (as indicated by tput) only supports 8 colours.

If you're using Konsole, check the configuration and change the session to xterm-256color. Alternatively can set the environment variable within your ~/.bashrc file like so: export TERM=xterm-256color

It works! Thank you very much and sorry for the inconveniece roll

snapshot4am.png

Kaustic wrote:

(PS: To list all the terminals you can use with 256 colours try the following command: (Iirc there was a cleaner way to do this, but alas)

ls /usr/share/terminfo/*/* | grep 256

The output:

/usr/share/terminfo/E/Eterm-256color
/usr/share/terminfo/d/darwin-256x96
/usr/share/terminfo/d/darwin-256x96-m
/usr/share/terminfo/g/gnome-256color
/usr/share/terminfo/k/konsole-256color
/usr/share/terminfo/m/mlterm-256color
/usr/share/terminfo/m/mrxvt-256color
/usr/share/terminfo/p/putty-256color
/usr/share/terminfo/r/rxvt-256color
/usr/share/terminfo/s/screen-256color
/usr/share/terminfo/s/screen-256color-bce
/usr/share/terminfo/s/screen-256color-bce-s
/usr/share/terminfo/s/screen-256color-s
/usr/share/terminfo/v/vte-256color
/usr/share/terminfo/x/xnuppc+256x96
/usr/share/terminfo/x/xnuppc-256x96
/usr/share/terminfo/x/xnuppc-256x96-m
/usr/share/terminfo/x/xterm+256color
/usr/share/terminfo/x/xterm-256color

How I put xterm-256color by default?

Offline

#15 2012-03-27 11:55:23

Earnestly
Member
Registered: 2011-08-18
Posts: 805

Re: [SOLVED] Vim color scheme

Midnith wrote:

How I put xterm-256color by default?

Kaustic wrote:

Alternatively can set the environment variable within your ~/.bashrc file like so: export TERM=xterm-256color

Midnith wrote:

Thank you very much and sorry for the inconveniece

No problem, that's what these forums are for smile. Don't forget to mark this as [SOLVED] so tourists from Google can see it.

Last edited by Earnestly (2012-03-27 11:57:01)

Offline

#16 2012-03-27 11:57:31

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [SOLVED] Vim color scheme

As Kaustic wrote you can put it right in your ~/.bashrc file

export TERM=xterm-256color

If possible it's better to just get your terminal to do this itself, but I know nothing about konsole.  Check it's preferences and settings and see if it has an option for this.  I suspect there isn't - so the bashrc setting would be the way to go.

EDIT: he beat me to it.

Last edited by Trilby (2012-03-27 11:57:50)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#17 2012-03-27 20:25:23

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,094

Re: [SOLVED] Vim color scheme

Setting TERM in .bashrc should _never_ be done _ever_

The TE/multiplexer itself should set the TERM correctly. Else it will just break the second you try to use some different TE, or a multiplexer like screen/tmux.


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#18 2012-03-27 21:07:08

Earnestly
Member
Registered: 2011-08-18
Posts: 805

Re: [SOLVED] Vim color scheme

Mr.Elendig wrote:

Setting TERM in .bashrc should _never_ be done _ever_

The TE/multiplexer itself should set the TERM correctly. Else it will just break the second you try to use some different TE, or a multiplexer like screen/tmux.

I get that, but this doesn't solve the issue of Vim and other tools not making use of 256 colours. How would you personally fix this without setting the TERM variable? For the sake of screen/tmux, I don't care, with Arch I know what's on my system and can easily adjust accordingly. (I use screen-256color)

However as you've mentioned some fairly obvious downsides (which I've experienced with tmux) I'd like to hear any suggestions you might have on this topic and how you might resolve it. smile

Thanks

edit: Do you essentially have to rely on application specific settings to force the option? (E.g. vim: set t_Co=256 & tmux: set -g default-terminal "screen-256color")

Last edited by Earnestly (2012-03-27 21:13:52)

Offline

#19 2012-03-27 23:22:54

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [SOLVED] Vim color scheme

If a terminal supports 256 colors it should set the TERM variable to something other applications can recognize as 256 color capable.  But this can go wrong at 2 places: first, not all apps recognize all possible options of TERM, and seocnd not all terminal emulators set this variable properly.  I'd recommending avoiding setting TERM in bashrc - but if Konsole doesn't have an option to set it properly then the bashrc method is a suitable workaround.  This workaround may have some undesirable side-effects - but it gets the job done and seems the lesser of two evils in this case (until a good konsole user or dev can say how to do this properly).

Last edited by Trilby (2012-03-27 23:23:14)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#20 2012-03-28 00:23:00

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: [SOLVED] Vim color scheme

To set the $TERM variable for Konsole:

In Konsole, on the menu bar, click "Settings >> Configure Current Profile..."

In the dialog box, on the "General" tab, next to the word "Environment:", click the button, the only button, labeled "Edit".

In the text box that pops up, change "TERM=xterm" to "TERM=xterm-256color".  Keep hitting the "OK" buttons to back out of all the dialog boxes, close the current konsole and start a new konsole session.

Now,

$ echo $TERM
xterm-256color

Now I'll go uninstall konsole.

Offline

#21 2012-03-28 03:03:53

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] Vim color scheme

thisoldman wrote:

Now I'll go uninstall konsole.

Taking one for the team!

cookie > thisoldman


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#22 2012-03-28 10:18:02

Earnestly
Member
Registered: 2011-08-18
Posts: 805

Re: [SOLVED] Vim color scheme

thisoldman wrote:

To set the $TERM variable for Konsole

That's what I said, in far fewer words (playing around in a Mint KDE vm).

So essentially one must basically rely on the programs to correctly set the environment or configure each one to do so?

I can live with that, although using "screen-256color" has given me no trouble yet (rxvt-unicode-256color caused issues in tmux).

Offline

#23 2012-03-28 11:20:57

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: [SOLVED] Vim color scheme

Kaustic wrote:

So essentially one must basically rely on the programs to correctly set the environment or configure each one to do so?

Setting the $TERM value by app is a better solution, I think, than setting it globally.  If, for some reason, I need to use a tty, I want TERM=linux, not xterm.  Most people soon settle into a favorite terminal emulator, so the editing of configuration files or settings probably isn't a great task.  We're Arch users; we edit configuration files just out of curiosity.  "I wonder what will happen if..."

Offline

Board footer

Powered by FluxBB