Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get "syntax on" to work in my gvim

Tags:

syntax

vim

(I'm new to Linux and Vim, and I'm trying to learn Vim but I'm having some issues with it that I can't seen do fix)

I'm in a Linux installation (Ubuntu 8.04) that I can't update, using Vim 7.1.138.

My vim installation is in /usr/share/vim/vim71/. /home/user/

My .vimrc file is in /home/user/.vimrc, as follows:

fun! MySys()
    return "linux"
endfun

set runtimepath=~/.vim,$VIMRUTNTIME
source ~/.vim/.vimrc

And then, in my /home/user/.vim/.vimrc:

" =============== GENERAL CONFIG ==============
set nocompatible
syntax on

" =============== ENCODING AND FILE TYPES =====
set encoding=utf8
set ffs=unix,dos,mac

" =============== INDENTING ===================
set ai " Automatically set the indent of a new line (local to buffer)
set si " smartindent (local to buffer)

" =============== FONT ========================
" Set font according to system
if MySys() == "mac"
  set gfn=Bitstream\ Vera\ Sans\ Mono:h13
  set shell=/bin/bash
elseif MySys() == "windows"
  set gfn=Bitstream\ Vera\ Sans\ Mono:h10
elseif MySys() == "linux"
  set gfn=Inconsolata\ 14
  set shell=/bin/bash
endif

" =============== COLORS ======================
colorscheme molokai

" ============== PLUGINS ======================
" -------------- NERDTree ---------------------
:noremap ,n :NERDTreeToggle<CR>

" =============== DIRECTORIES =================
set backupdir=~/.backup/vim
set directory=~/.swap/vim

...fact is the command syntax on is not working, neither in vim or gvim. And the strange thing is: If I try to set the syntax using the gvim toolbat, it works. Then, in normal mode in gvim, after activating using the toolbar, using the code :syntax off, it works, and just after doing this trying to do :syntax on doesn't work!!

I have the syntax files in both /usr/share/vim/vim71/ and home folders (in the home there's only a python syntax module). I've run sudo aptitude install vim as well and there's nothing do download, EXCEPT vim-gtk, since I was afraid of some kind of incompatibility.

What's going on? Am I missing something?

like image 461
Somebody still uses you MS-DOS Avatar asked Feb 27 '23 01:02

Somebody still uses you MS-DOS


2 Answers

Let's break this down into something simple. Instead of trying to debug multiple possible points of failure (source, runtimepath), see if the simplest case works. Then, add back in each piece until something breaks.

First of all, make sure your ~/.vimrc/ and ~/.vim/.vimrc are checked into version control or save off a copy. Also, unless you've modified the original python syntax module for some reason, there should be no need to have it located in your ~/.vim directory.

Now, delete the contents of both .vimrc files and add only the following two lines to your ~/.vimrc file.

filetype plugin on
syntax on

Now, open up a new vim session with the file you're trying to syntax highlight. Does it work? I would expect this to work in most cases if the filetype is being detected properly.

:set filetype?

If the syntax highlighting isn't working and the filetype is correct there's something more wrong than just your .vimrc files. You could try removing your ~/.vim directory too to see if that's the problem.

I'm not sure why you're setting your runtimepath but when I check mine, it shows ~/.vim as the first entry (and there are a lot more directories than just VIMRUNTIME) by default so that line shouldn't be necessary.

:set runtimepath?

Also, VIMRUNTIME is misspelled. I expect this is your problem. If I use your set runtimepath from above, I lose syntax highlighting as well.

Hope this helps.

like image 85
Curt Nelson Avatar answered Mar 05 '23 16:03

Curt Nelson


Ubuntu default install doesn't install all of vim.

sudo apt-get install vim
like image 37
Nick Canzoneri Avatar answered Mar 05 '23 16:03

Nick Canzoneri