Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to make some basic customizations to vim. All I want is some syntax highlighting, etc. Basically, not just plain text.

My .vimrc file consists of 7 lines:

backspace=2
syntax on
filetype indent on
set autoindent
set number
colorscheme desert
set nobackup

Every time I launch vim, I get these errors and see no syntax highlighting:

E492: Not an editor command: backspace=2
E484: Can't open file /usr/share/vim/syntax/syntax.vim

The latter problem just might stem from the fact that I don't have a /usr/share/vim folder. I would have thought that this would have been created when I installed vim. So, what do I do now?

share|improve this question

migrated from stackoverflow.com Nov 24 '11 at 23:14

This question came from our site for professional and enthusiast programmers.

    
How exactly did you install vim? What does dpkg -l | grep vim say? –  Keith Thompson Nov 24 '11 at 4:09
add comment

2 Answers

First things first, sit back, relax, and take a few deep breaths. Okay, relaxed now?

For the first error, you need:

set backspace=2

The second one I can only assume occurred becaue you're not using the standard vim that ships with Ubuntu, or your environment has become broken somehow. What you probably need to do is actually find the syntax file with something like:

find / -name syntax.vim 2>/dev/null

and then ensure that your VIMRUNTIME environment variable is set correctly for that (for example, if the file was located at /xyzzy/plugh/syntax/syntax.vim, then you would set the variable to be /xyzzy/plugh).

share|improve this answer
    
find / -name syntax.vim could take a very long time to run, and produce a lot of error messages as it fails to read various system directories. –  Keith Thompson Nov 24 '11 at 4:01
    
@Keith, unless you can narrow it down, you'll have to search everywhere. I'll update the answer to get rid of any errors but I would run this as root anyway because I'm either brave or stupid - sometimes it's hard to tell :-) –  paxdiablo Nov 24 '11 at 4:04
1  
Knowing how vim was installed would likely help track down the location of syntax.vim more quickly than find / .... But if vim can't find its own files, it's likely they don't exist. –  Keith Thompson Nov 24 '11 at 4:12
    
Thanks. I fixed the first problem. Not difficult as expected. The second is like speaking a different language. I ran that search and it came up empty. You are right, the standard vim was broken (this is part of long series of problems), so I installed vim73 from a download. I would LOVE to get back to the standard version. Is there a way to do that? Otherwise, I have no earthly idea of how to ensure that my VIMRUNTIME environment variable is set correctly. Stuff like this is a good example of my frustration with Linux, but that's another matter. Thanks for your help. –  user1024973 Nov 24 '11 at 4:18
1  
@user1024973: I'm still running 11.04 but it's probably the case that 11.10 still uses Synaptic for package management. I would start by doing a search within there for vim and possibly re-installing. –  paxdiablo Nov 24 '11 at 4:26
show 3 more comments

For the first error, you're setting an option. That uses the set command, and that's all there is to it.

set backspace=2

For the second error, you're missing the system file /usr/share/vim/syntax/syntax.vim. That means you need to install the package that provides this file. There is a generic method to find out what that package is, for any file provided by Ubuntu. (The same method works on Debian, mutatis mutandis.)

On http://packages.ubuntu.com, search the contents of packages for the keyword syntax.vim. This leads you to the vim-runtime package. You can also perform this search on your machine if you install the apt-file package, by running the command apt-file search syntax.vim.

In this case, you need more than just the vim-runtime package. In fact, don't install it now, read on. The default Ubuntu installation only includes a tiny version of vim that lacks most bells and whistles (it's just meant as a quick way of editing a configuration file). For serious work, you need to install a full version of vim. You have a choice of no GUI or various GUIs. All of the non-tiny versions pull in the usual advanced features such as syntax highlighting (they depend on the vim-runtime package).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.