Unable to get "syntax" to work in my gvim

(I am new to Linux and Vim, and I'm trying to learn Vim, but I have some problems with it that I have not seen, I fix it)

I am in a Linux installation (Ubuntu 8.04) which I cannot update using Vim 7.1.138.

My vim installation is located in /usr/share/vim/vim71/ ./Main/user/

My .vimrc file is located in /home/user/.vimrc , as shown below:

 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 - the syntax on command does not work, neither in vim nor in gvim. And strange: if I try to set the syntax using gvim toolbat, it works . Then, in normal mode in gvim, after activation using the toolbar, using the code :syntax off , it works, and only after that try to do :syntax on does not work !!

I have syntax files in /usr/share/vim/vim71/ as well as in home folders (there is only a python syntax module in the house). I also ran sudo aptitude install vim and didn't download anything, EXCEPT vim-gtk , as I was afraid of some kind of incompatibility.

What's happening? Did I miss something?

+4
source share
3 answers

Let me break it down to something simple. Instead of trying to debug some possible points of failure ( source , runtimepath ), see if the simplest case works. Then add back to each piece until something breaks.

First of all, make sure your ~/.vimrc/ and ~/.vim/.vimrc are ~/.vim/.vimrc in version control or save a copy. In addition, if for some reason you did not modify the original python syntax module, it should not be necessary to place it in the ~/.vim .

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 a new vim session with the file you are trying to highlight with syntax. It works? I expect this to work in most cases if the file is detected correctly.

 :set filetype? 

If the syntax highlighting does not work and the filetype correct, then something is wrong there, as soon as your .vimrc files are. You can also try deleting your ~ / .vim directory to see if the problem is.

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

 :set runtimepath? 

In addition, VIMRUNTIME has a spelling error. I expect this is your problem. If I use your set runtimepath on top, I also lose syntax highlighting.

Hope this helps.

+7
source

Installing Ubuntu by default does not install all vim.

 sudo apt-get install vim 
+1
source

Try adding filetype plugin on to syntax on in your .vimrc.

0
source

Source: https://habr.com/ru/post/1309135/


All Articles