LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 07-14-2007, 07:28 AM   #1
mehrots
LQ Newbie
 
Registered: May 2007
Posts: 15

Rep: Reputation: 0
syntax highlighting in vi


Hi..

I am using Redhat Enterprise linux 5.
i wanted to turn on syntax highlighting on in Vi

so as a *root*
______________________________________________________________________
I opened vi
~vi test.c
pressed ESC
:syntax on
______________________________________________________________________

now nothing happened... getting the same single color syntax
tried including "set syntax=on" in /etc/vimrc

but has not helped..
****************************************

CAN SOME ONE HELP IN THIS REGARD (in detail)

Thx.
mehrots
 
Old 07-14-2007, 11:20 AM   #2
ak_random
Member
 
Registered: Jun 2007
Location: Silicon Valley, CA
Distribution: Xubuntu
Posts: 83

Rep: Reputation: 15
First, you need to make sure that when you type "vi" you are actually getting vim. You probably are, but you should make sure, since the ":syntax on" command is a vim command. Next, check if this copy of vim has syntax highlighting enabled as a feature. Do this by entering ":ver" and look for "+syntax". If you see "-syntax", then this copy of vim does not have it. If it does have it, you need to make sure your console/terminal supports colors. Are you running from the Linux console? Or are you running from within a terminal shell like xterm or rxvt?

As an alternative, if you are running from a modern desktop environment, you can try the graphical version of vim by running gvim.

So these aren't complete instructions, but it's a starting point. I suggest you may want to ask your question on a vim mailing list since these questions come up all the time.
 
Old 07-14-2007, 05:01 PM   #3
bartonski
Member
 
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Blog Entries: 1

Rep: Reputation: 48
You may also want to check to make sure that vi isn't aliased to `/usr/bin/vim -v'; the -v option will open vim in vi mode, ie. using traditional vi keybindings and features.
 
Old 07-15-2007, 03:17 AM   #4
mehrots
LQ Newbie
 
Registered: May 2007
Posts: 15

Original Poster
Rep: Reputation: 0
Hi ,

Thx for your response..

@ak_random --I tried finding about the mailing list but could not find any mailing list related to VI

Pls treat me as a newbie and help coz im not able to fully follow..

@bartonski -- thx for reply can u pls expand.. im not following u..

regards,

mehrots
 
Old 07-15-2007, 03:28 AM   #5
mehrots
LQ Newbie
 
Registered: May 2007
Posts: 15

Original Poster
Rep: Reputation: 0
Hi,

I did check the :ver

COULD NOT FIND +syntax or -syntax

how do i make sure im getting VIM..?

The terminal/console has colors..
as when i do "ls" the dir/files etc .. come in different colors..

tried running gvim..
but there colors have to select everytime.. the feature for C language..

thx.
mehrots
 
Old 07-15-2007, 04:18 AM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
What happens if you invoke vim rather than vi?
And if that works, just make an alias.


Cheers,
Tink
 
Old 07-15-2007, 04:36 AM   #7
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
After giving the ':syntax on' command, you probably also need to specify a color scheme: ":colorscheme blue" (without quotes).

Then save yourself some effort, and create a .vimrc file in your home folder. In the file, put the options you want vim to startup with everytime you launch vim.

Example .vimrc:

syntax on
:colorscheme blue

# set vim tab spacing
:set expandtab
:set softtabstop=3
:set tabstop=3
:set shiftwidth=3
:set foldmethod=indent
:set backspace=2
:set ruler

In SuSE 9.3, the colorschemes are located in /opt/kde3/share/vim/vim62/colors.
 
Old 07-15-2007, 05:03 AM   #8
mehrots
LQ Newbie
 
Registered: May 2007
Posts: 15

Original Poster
Rep: Reputation: 0
[root@dhcppc1 bin]# vim
No Syntax items defined for this buffer
Press ENTER or type command to continue

NOW when i press "return" i get in VIM..

but that does not solve the problem..
 
Old 07-15-2007, 05:45 AM   #9
mehrots
LQ Newbie
 
Registered: May 2007
Posts: 15

Original Poster
Rep: Reputation: 0
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=utf-8,latin1
endif


set nocompatible " Use Vim defaults (much better!)
set bs=indent,eol,start " allow backspacing over everything in insert mode
set ai " always set autoindenting on
"set backup " keep a backup file
set viminfo='20,\"50 " read/write a .viminfo file, don't store more
" than 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
syntax on " syntax on
colorscheme default " syntax highlighting on
set autoindent

" Only do this part when compiled with support for autocommands
if has("autocmd")
" In text files, always limit the width of text to 78 characters
autocmd BufRead *.txt set tw=78
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
endif

if has("cscope") && filereadable("/usr/bin/cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
endif



*******************************************************************
this is my vimrc file..

when im typing vim in console/terminal
I get the following error.
[root@dhcppc1 bin]# vim
No Syntax items defined for this buffer
Press ENTER or type command to continue

NOW when i press "return" i get in VIM..
*******************************************************************
 
Old 07-15-2007, 01:24 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
And if you open some code file while opening vim?
E.g. vim ~/.bashrc



Cheers,
Tink
 
Old 07-16-2007, 08:50 AM   #11
mehrots
LQ Newbie
 
Registered: May 2007
Posts: 15

Original Poster
Rep: Reputation: 0
Hi ,

Im getting the "syntax highlighting" when im opening the file ~/.bashrc

rgds,
mehrots
 
  


Reply



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
[SOLVED] vim without syntax highlighting lord_didger Debian 5 11-18-2006 01:29 PM
C++ syntax highlighting with PHP ckoniecny Programming 1 08-11-2006 07:09 AM
GVIM syntax highlighting gone! kdogksu Linux - Software 4 02-24-2006 09:47 PM
syntax highlighting rohr Programming 3 07-06-2005 06:07 AM
Vim syntax highlighting NSKL Linux - Software 2 11-09-2002 02:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:08 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
Open Source Consulting | Domain Registration