write 'set t_Co=256', scroll and keybind problems

56 views
Skip to first unread message

madiyaan

unread,
Jan 12, 2008, 11:29:13 AM1/12/08
to vim_use
Hello all:

Firstly, thank you all the developers for creating such a useful
editor.

I have customized my .vimrc file to have some custom mappings, colors,
etc.
That all works well in MS Windows. However, when I use the same .vimrc
file
in a Unix/Linux environment, some of the features don't work. In
specific,
when I start gvim or vim, I get the following message:

write 'set t_Co=256' in your .vimrc file or this won't load

I couldn't find this in my .vimrc file, so I thought it would be in my
colorscheme. However, this message appears even if I comment out my
colorscheme line in the .vimrc file. I would appreciate if someone
could
elucidate me on this matter, and how to rectify it.

Secondly, I have the following mappings:

noremap <Space> <PageDown>
noremap <S-Space> <PageUp>

However, in Linux, running vim inside the gnome-terminal 2.18.2 (or
when
running gvim), both space and shift-space do page-down operation. I
can't
figure out the source of this problem. Note that the exact same .vimrc
file
works perfectly in MS Windows, i.e. shift-space does page-up.

[This might be a VMWare specific problem, since I am running Ubuntu
Linux
inside VMWare, but I am not sure. In principle it shouldn't happen).

Third, vim (the command line) when running on gnome-terminal 2.18.2
has this
strange behavior: whenever a key is pressed, it shows the key down
below and
the last line scrolls up. Perhaps this can be best explained using a
screenshot, whose link I am putting in this email. Before capturing
this
screenshot, I pressed j j j k Esc Esc i. Text that I type also does
not
appear at the top of the screen. Is this a known problem?

Screenshot below:

http://img100.imageshack.us/img100/8112/vimhelppu8.png

For your information, I am running Ubuntu 7.10 and using gnome-
terminal
2.18.2. The vim version is: 7.1.

If anyone wants my complete .vimrc file, I can reply to this message
and
upload it.

Regards,

P.S. If anything is unclear, please let me know. Fixing these problems
will
greatly boost my productivity.

Ben Schmidt

unread,
Jan 12, 2008, 12:49:47 PM1/12/08
to vim...@googlegroups.com
> write 'set t_Co=256' in your .vimrc file or this won't load

It looks like you are trying to load a colour scheme that needs 256 colours, but
your terminal doesn't have that many colours (or Vim doesn't know it does). So,
you either need to add the line set t_Co=256 into your .vimrc, or set your $TERM
environment variable (before starting Vim) to something appropriate.

> I couldn't find this in my .vimrc file, so I thought it would be in my
> colorscheme. However, this message appears even if I comment out my
> colorscheme line in the .vimrc file. I would appreciate if someone
> could
> elucidate me on this matter, and how to rectify it.

That is a bit odd. There may be something else expecting 256 colours, I guess, but
I'm not sure what it might be.

> noremap <Space> <PageDown>
> noremap <S-Space> <PageUp>
>
> However, in Linux, running vim inside the gnome-terminal 2.18.2 (or
> when
> running gvim), both space and shift-space do page-down operation. I
> can't
> figure out the source of this problem. Note that the exact same .vimrc
> file
> works perfectly in MS Windows, i.e. shift-space does page-up.

This isn't surprising. A lot of keys such as shift-space won't work in terminals,
but only in the Vim GUI (gvim or vim -g). In a terminal, both space and
shift-space produce the same code, so Vim can't tell the difference.

If you are under Gnome, maybe try compiling in the GTK/GTK2 GUI of Vim; that would
probably work.

> Third, vim (the command line) when running on gnome-terminal 2.18.2
> has this
> strange behavior: whenever a key is pressed, it shows the key down
> below and
> the last line scrolls up. Perhaps this can be best explained using a
> screenshot, whose link I am putting in this email. Before capturing
> this
> screenshot, I pressed j j j k Esc Esc i. Text that I type also does
> not
> appear at the top of the screen. Is this a known problem?
>
> Screenshot below:
>
> http://img100.imageshack.us/img100/8112/vimhelppu8.png

Yuck!

My suspicion would be that 'columns' or 'rows' is set incorrectly to something
other than what the window size actually is. Does resizing the window help? Maybe
try setting those options manually ':set columns=80 rows=24' or such.

It could be related to the earlier problems, too, if the $TERM is set wrong, Vim
may not be able to properly find its size, etc. Odd though.

You may also find it handy to start Vim as 'vim -u NONE -U NONE -N' to start it in
nocompatible mode but without loading your .vimrc or any plugins. Then you will be
able to find out whether it is a Vim problem alone, or something that only shows
up with certain settings. If it is something with your settings, you should be
able to track it down by removing parts of your .vimrc, etc. until it goes away.

Anyway, those are my initial ideas. Others may be able to expand more (e.g. they
may know what your $TERM should be).

Ben.

Send instant messages to your online friends http://au.messenger.yahoo.com

Matt Wozniski

unread,
Jan 12, 2008, 1:57:31 PM1/12/08
to vim...@googlegroups.com
On Jan 12, 2008 12:49 PM, Ben Schmidt wrote:
>
> > write 'set t_Co=256' in your .vimrc file or this won't load
>
> It looks like you are trying to load a colour scheme that needs 256 colours, but
> your terminal doesn't have that many colours (or Vim doesn't know it does). So,
> you either need to add the line set t_Co=256 into your .vimrc, or set your $TERM
> environment variable (before starting Vim) to something appropriate.

Yep.

> > I couldn't find this in my .vimrc file, so I thought it would be in my
> > colorscheme. However, this message appears even if I comment out my
> > colorscheme line in the .vimrc file. I would appreciate if someone
> > could
> > elucidate me on this matter, and how to rectify it.
>
> That is a bit odd. There may be something else expecting 256 colours, I guess, but
> I'm not sure what it might be.

I've written a plugin that requires t_Co == 256, and set it to a few
people on #vim. On colorscheme changed events, it tries to use the
colors that were set for guifg and guibg to set ctermbg and ctermfg to
something on the 256-color cube. Not nearly as nice as the patch that
I still haven't gotten any feedback on, but my first attempt, and
works well enough for what it is. Just had a few shortcomings that
can't really be overcome in script...

> > noremap <Space> <PageDown>
> > noremap <S-Space> <PageUp>
> >
> > However, in Linux, running vim inside the gnome-terminal 2.18.2 (or
> > when
> > running gvim), both space and shift-space do page-down operation. I
> > can't
> > figure out the source of this problem. Note that the exact same .vimrc
> > file
> > works perfectly in MS Windows, i.e. shift-space does page-up.
>
> This isn't surprising. A lot of keys such as shift-space won't work in terminals,
> but only in the Vim GUI (gvim or vim -g). In a terminal, both space and
> shift-space produce the same code, so Vim can't tell the difference.

Yes, though some decent terminal emulators let you add new keys
(xterm, for one). For instance, I have, in my .Xdefaults, the
following lines for xterm keys:
*VT100.Translations: #override \
<Key>Delete: string("\033[3~")\n\
~Meta Shift<Key>Tab: string("\033[Z") \n\
Meta Shift<Key>Tab: string("\033\033[Z") \n

In addition to making sure that delete sends the code I want, this
lets me use shift-tab and alt-shift-tab in a terminal. You could add
a code for shift-space in the same way.

> If you are under Gnome, maybe try compiling in the GTK/GTK2 GUI of Vim; that would
> probably work.
>

Certainly would fix the keybinding problem, anyway.

> > Third, vim (the command line) when running on gnome-terminal 2.18.2
> > has this
> > strange behavior: whenever a key is pressed, it shows the key down
> > below and
> > the last line scrolls up. Perhaps this can be best explained using a
> > screenshot, whose link I am putting in this email. Before capturing
> > this
> > screenshot, I pressed j j j k Esc Esc i. Text that I type also does
> > not
> > appear at the top of the screen. Is this a known problem?
> >
> > Screenshot below:
> >
> > http://img100.imageshack.us/img100/8112/vimhelppu8.png
>
> Yuck!
>
> My suspicion would be that 'columns' or 'rows' is set incorrectly to something
> other than what the window size actually is. Does resizing the window help? Maybe
> try setting those options manually ':set columns=80 rows=24' or such.

My guess would be that you are setting one or both of those options
manually. In gvim, or a sane terminal like xterm, setting those
options to a higher value than actual will resize the window to what
you specify, but gnome-terminal is a piece of crap. So, if you're
setting 'columns' or 'rows' manually, that should be done in .gvimrc,
not .vimrc.

> It could be related to the earlier problems, too, if the $TERM is set wrong, Vim
> may not be able to properly find its size, etc. Odd though.
>
> You may also find it handy to start Vim as 'vim -u NONE -U NONE -N' to start it in
> nocompatible mode but without loading your .vimrc or any plugins. Then you will be
> able to find out whether it is a Vim problem alone, or something that only shows
> up with certain settings. If it is something with your settings, you should be
> able to track it down by removing parts of your .vimrc, etc. until it goes away.

Yep.

> Anyway, those are my initial ideas. Others may be able to expand more (e.g. they
> may know what your $TERM should be).

The real reason I replied was because I knew this one ;-) The proper
$TERM setting for a 256 color gnome terminal is "gnome-256color". On
an ubuntu system, like most others, this terminfo entry isn't
installed by default, but you can get it by installing the package
"ncurses-term". Unfortunately, I don't know of any way to change what
gnome terminal sets $TERM to when starting. If any one does, please
chip in, since no one but the terminal should ever need to change
$TERM!

~Matt

ahmad...@gmail.com

unread,
Feb 4, 2008, 4:55:04 PM2/4/08
to vim_use
I have not tried this and it might even work, but I am mostly
interested in getting shift-space work in gvim (the gui version of
Vim). In either case, do you know what would be the equivalent for
gnome-terminal (the Ubuntu terminal that I use)?

>
> In addition to making sure that delete sends the code I want, this
> lets me use shift-tab and alt-shift-tab in a terminal. You could add
> a code for shift-space in the same way.
>
> > If you are under Gnome, maybe try compiling in the GTK/GTK2 GUI of Vim; that would
> > probably work.
>
> Certainly would fix the keybinding problem, anyway.

Is it possible to fix this somehow without recompiling? If there is no
other way, can you please guide me how to do this? I mean should I
recompile gvim with some specific settings or flags?

Thanks,

Ben Schmidt

unread,
Feb 4, 2008, 6:11:21 PM2/4/08
to vim...@googlegroups.com
>>> If you are under Gnome, maybe try compiling in the GTK/GTK2 GUI of Vim; that would
>>> probably work.
>> Certainly would fix the keybinding problem, anyway.
>
> Is it possible to fix this somehow without recompiling? If there is no
> other way, can you please guide me how to do this? I mean should I
> recompile gvim with some specific settings or flags?

To compile the GTK/GTK2 GUI you should only need to make sure you have the GTK
development package installed for you OS so you have all the relevant headers, and
then pass --enable-gui=gtk or --enable-gui=gtk2 to ./configure for Vim.

ahmad...@gmail.com

unread,
Feb 15, 2008, 4:00:01 PM2/15/08
to vim_use
Is it possible to have shift-space as a shortcut in vim (not the
graphical version, gvim). Is there some shell/console setting that I
can do that allows vim to capture shift-space as opposed to treating
it like space?

Regards,

Tony Mechelynck

unread,
Feb 15, 2008, 4:11:57 PM2/15/08
to vim...@googlegroups.com
ahmad...@hotmail.com wrote:
> Is it possible to have shift-space as a shortcut in vim (not the
> graphical version, gvim). Is there some shell/console setting that I
> can do that allows vim to capture shift-space as opposed to treating
> it like space?
>
> Regards,

Normally, space and shift-space are the same. You might program X11 to send
something else of your choosing (see "man xmodmap"), but then Insert-mode Vim
won't recognize shift-space as space unless you remap it the other way round.


Best regards,
Tony.
--
Everyone can be taught to sculpt: Michelangelo would have had to be
taught how _not_ to. So it is with the great programmers.

Reply all
Reply to author
Forward
0 new messages