Why can't vim find syntax.vim on my fresh Ubuntu installation?
Solution 1
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
).
Solution 2
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).
Related videos on Youtube
AndroidDev
Updated on September 18, 2022Comments
-
AndroidDev over 1 year
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?-
Keith Thompson over 12 yearsHow exactly did you install vim? What does
dpkg -l | grep vim
say?
-
-
Keith Thompson over 12 years
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. -
Admin over 12 years@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 :-)
-
Keith Thompson over 12 yearsKnowing how vim was installed would likely help track down the location of
syntax.vim
more quickly thanfind / ...
. But ifvim
can't find its own files, it's likely they don't exist. -
Admin over 12 yearsThanks. 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.
-
Admin over 12 years@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.
-
Admin over 12 yearsWhat was broken in the standard Vim? Where and how did you install your own Vim?
-
Admin over 12 years@user1024973 AFAIK by default Ubuntu ships with minimal vim setup (“vim-tiny”): with most features disabled and without runtime files. You have to install full vim version (named just “vim”), this will also pull runtime files (package “vim-runtime”). You can install runtime files with vim-tiny, but I won’t be surprised if you will then discover that syntax support was disabled at compile time and it still won’t highlight anything.
-
naught101 over 11 yearsFor the second error, it might be worth trying
unset VIMRUNTIME
before trying to export it. That worked for me.