Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Syntax coloring in vi (elvis) under 13.1

231 views
Skip to first unread message

S.K.R. de Jong

unread,
Feb 10, 2011, 4:30:40 PM2/10/11
to
I am trying to get the elvis editor to do syntax coloring for C
files in Slackware 13.1, so far without any success. After doing a google
search I was led to believe that issuing the following commands at the
editor should do the trick:

:display syntax :color normal white :color bold yellow :color
emphasized green :color italic cyan :color fixed red

However, this has not worked - when editing a C file, after issuing these
commands there is no syntax coloring whatsoever.

Suggestions, anyone?

Sylvain Robitaille

unread,
Feb 10, 2011, 5:38:31 PM2/10/11
to
On Thu, 10 Feb 2011 21:30:40 +0000 (UTC), S.K.R. de Jong wrote:

> I am trying to get the elvis editor to do syntax coloring for C

> files in Slackware 13.1, so far without any success. ...

The following worked for me while testing:

:display syntax
:color normal white

:color prepquote green
:color function cyan
:color string red

I don't normally use "elvis", preferring cim (and having aliased "vi" to
"vim"), so I can't tell you for sure whether what I've done is *the* way
to get this in elvis, but it seems to have produced the expected result.
See /usr/share/elvis-2.2_0/elvis.syn for the character/word "classes"
that apply in the case of C source in elvis.

I hope this helps ...

--
----------------------------------------------------------------------
Sylvain Robitaille s...@encs.concordia.ca

Systems analyst / AITS Concordia University
Faculty of Engineering and Computer Science Montreal, Quebec, Canada
----------------------------------------------------------------------

Emilio

unread,
Feb 13, 2011, 12:48:17 AM2/13/11
to

Sigh. Pat links vi -> elvis just to see if you are paying attention.

As root:

cd /usr/bin
ls -l vi*
rm -v vi
ln -sv vim vi

Now vi points to vim which is probably what you want.

Cheers,

Dan C

unread,
Feb 13, 2011, 12:53:55 AM2/13/11
to

Lots of extra typing there...

Easier to do (as root):

cd /usr/bin
ln -sf vim vi

> Now vi points to vim which is probably what you want.

Indeed.


--
"Ubuntu" -- an African word, meaning "Slackware is too hard for me".
"Bother!" said Pooh, as he backed into a squad car.
Usenet Improvement Project: http://twovoyagers.com/improve-usenet.org/
Thanks, Obama: http://brandybuck.site40.net/pics/politica/thanks.jpg

Loki Harfagr

unread,
Feb 13, 2011, 5:20:17 AM2/13/11
to
Sun, 13 Feb 2011 05:53:55 +0000, Dan C did cat :

> On Sun, 13 Feb 2011 05:48:17 +0000, Emilio wrote:
>
>> On Thu, 10 Feb 2011 21:30:40 +0000, S.K.R. de Jong wrote:
>>
>>> I am trying to get the elvis editor to do syntax coloring for C files
>>> in Slackware 13.1, so far without any success. After doing a google
>>> search I was led to believe that issuing the following commands at the
>>> editor should do the trick:
>>>
>>> :display syntax :color normal white :color bold yellow :color
>>> emphasized green :color italic cyan :color fixed red
>>>
>>> However, this has not worked - when editing a C file, after issuing
>>> these commands there is no syntax coloring whatsoever.
>>>
>>> Suggestions, anyone?
>>
>> Sigh. Pat links vi -> elvis just to see if you are paying attention.

misinterpretation here, it's probably elvis just "because it works"

>>
>> As root:
>>
>> cd /usr/bin
>> ls -l vi*
>> rm -v vi
>> ln -sv vim vi
>
> Lots of extra typing there...
>
> Easier to do (as root):
>
> cd /usr/bin
> ln -sf vim vi
>
>> Now vi points to vim which is probably what you want.

that'd be weird to "want" vim while you already have a better vi in elvis
but if you absolutely want to think that you need to demand vim just
mind to repair it:
alias vim="vim -u NONE "

or you'll be plagued with suxtux cuhluhring, wiggly parens, shaky
deplacements and blinking flubbers.

Vim can be a choice for hobbyists that edit ten lines files twice a
year but if you have to work on actual code you want to read the code
and only the code, not the frantic frolicking octocoloured follies
imagined by amateur hour animation studio west coast's third assistant.

>
> Indeed.

S.K.R. de Jong

unread,
Feb 13, 2011, 10:05:04 AM2/13/11
to
On Thu, 10 Feb 2011 21:30:40 +0000, S.K.R. de Jong wrote:

I finally found it. First, the command line above is wrong;
instead of, say,

:color bold yellow

one would have to do

:color function bold yellow

or prepquote, or string, etc. as Mr. Robitaille illustrated - thank you.
Second, after having typed the relevant color commands at my elvis
session, the

:mkexrc

command will create a .exrc file in my home directory so those settings
get automatically loaded every time.

Aaron W. Hsu

unread,
Feb 13, 2011, 2:10:10 PM2/13/11
to
On Sun, 13 Feb 2011 05:20:17 -0500, Loki Harfagr
<l0...@thedarkdesign.free.fr.invalid> wrote:

>> On Sun, 13 Feb 2011 05:48:17 +0000, Emilio wrote:
>>
>>> Sigh. Pat links vi -> elvis just to see if you are paying attention.
>
> misinterpretation here, it's probably elvis just "because it works"

Indeed. It works really well. The only thing preventing me from using it
right now is Unicode support, which I have as yet been unable to get to
work with Elvis.

> that'd be weird to "want" vim while you already have a better vi in elvis

Long live Elvis! Syntax highlighting in Elvis does work quite well and
there is some nice documentation for it in the online Elvis help. I do not
use syntax highlighting for the most part, but maybe you do...

> or you'll be plagued with suxtux cuhluhring, wiggly parens, shaky
> deplacements and blinking flubbers.

...or not.

> if you have to work on actual code you want to read the code
> and only the code, not the frantic frolicking octocoloured follies
> imagined by amateur hour animation studio west coast's third assistant.

Vim defaults can truly destroy a programmer's confidence in the classics.

Aaron W. Hsu

--
Programming is just another word for the lost art of thinking.

Sylvain Robitaille

unread,
Feb 13, 2011, 3:18:41 PM2/13/11
to
On 2011-02-13, Aaron W. Hsu wrote:

> Vim defaults can truly destroy a programmer's confidence in the
> classics.

So adjust the defaults to taste. Vim still has some features that make
it an improvement over a more "standard" (whose vi is "standard"
anymore?) vi.

You can make suitable adjustments to the defaults either in ~/.vimrc, or
/usr/share/vim/vimrc, depending on whether you want the altered
behaviour to apply to just your own user, or to be a new system
"default" setting. My systems all get the following change, which takes
care of the things that bother me most about vim:

--- /usr/share/vim/old/vimrc.original 2009-08-24 ...
+++ /usr/share/vim/vimrc 2009-12-12 ...
@@ -41,16 +41,9 @@
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>

-" In many terminal emulators the mouse works just fine, thus enable it.
-if has('mouse')
- set mouse=a
-endif
-
" 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

" Only do this part when compiled with support for autocommands.

I trust that anyone who would prefer to not have syntax highlighting on
by default can see exactly where to disable that. ...

Now, with that, I leave /usr/bin/vi alone, since others using my systems
might not expect vim when they type "vi". Instead I simply use a
command alias to give me vim when *I* type "vi".

Grant

unread,
Feb 13, 2011, 8:10:53 PM2/13/11
to

Agreed :) Though colorscheme=desert isn't too bad on my eyes, the default
is terrible. I load default ~/.vimrc and ~/.bash* from localnet on each
new install so the machines behave how I expect at the prompt.

Grant.
>
> Aaron W. Hsu

Aaron W. Hsu

unread,
Feb 13, 2011, 9:39:10 PM2/13/11
to
On Sun, 13 Feb 2011 20:10:53 -0500, Grant <o...@grrr.id.au> wrote:

> Agreed Though colorscheme=desert isn't too bad on my eyes, the default


> is terrible. I load default ~/.vimrc and ~/.bash* from localnet on each
> new install so the machines behave how I expect at the prompt.

Usually I set Vi compatibility mode, which gets close to something I can
use comfortably, but even that feels distinctly different than Vi proper
(nvi, elvis, or the original).

0 new messages