Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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..
****************************************
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.
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.
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.
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..
*******************************************************************
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.