Question

I've installed a fresh Arch Linux system on my laptop and downloaded the vim package.

I haven't altered the .vimrc file, but the syntax highlighting doesn't seem to work with any of the languages I tried (Python, Ruby, CSharp, C...).

Auto formatting (gg, =, G) also fails.

Until now when playing with vim (because I can't really say I've extensively used it) in other OSs (Ubuntu, Fedora), the syntax highlighting came on automatically. Is there something I am missing here?

Was it helpful?

Solution

You need to have following settings in .vimrc file as per arch linux documentation

filetype plugin on
syntax on

OTHER TIPS

This is the absolute minimum you need to put in your ~/.vimrc if you intend to use vim as your primary editor:

" activates filetype detection
filetype plugin indent on

" activates syntax highlighting among other things
syntax on

" allows you to deal with multiple unsaved
" buffers simultaneously without resorting
" to misusing tabs
set hidden

" just hit backspace without this one and
" see for yourself
set backspace=indent,eol,start

Anything else depends on your taste, workflow and needs.

vi /etc/profile
alias vi=vim

maybe you use vi instead of vim

I had this problem in Opensuse Leap 42.2 cloud. And solved it by installing vim-data

sudo zypper install vim-data

or just re-installing vim will include vim-data automatically.

sudo zypper remove vim
sudo zypper install vim

Type

:syntax on

to get it to work. It is not a default option for vim. Probably in the other systems, it was set to on in the system default vimrc

Or put

syntax on

in ~/.vimrc

Another reason syntax highlighting won't work is you might have a theme/colorscheme set that VIM cannot find.

colorscheme darkblue

Either delete the line or comment it out:

"colorscheme darkblue

I had a similar problem. I could not have syntax highlighting on. I also found that gvim launched without pulldown menus or toolbar icons. It turned out I did not have the vim-runtime package properly installed. In my case I was on debian jessie with a large set of files missing under /usr/share/vim/vim74/ directory.

$ ls /usr/share/vim/vim74/
debian.vim  doc/  rgb.txt

The solution was to run:

$ sudo aptitude reinstall vim-runtime

That fixed the problem for me, for syntax highlighting and for missing menus/icons in gvim. I'm not sure why my system was in this state, but the reinstall of the above package solved both issues.

in my case , I changed the term(terminal type) from vt100 to xterm. And it works.

To change the terminal type:

in bash:

export TERM=xterm

in bourne shell or ksh:

TERM=xterm
export TERM

in csh or tcsh:

setenv TERM xterm

On my Ubuntu 18.04 system i.e. c-highlighting works but Icinga2 config file highlighting being provided by the vim-icinga2 package does not. Quote from https://packages.debian.org/sid/vim-icinga2:

As per the Debian vim policy, installed addons are not activated automatically, but the "vim-addon-manager" tool can be used for this purpose.

Executing vim-addon-manager -w install icinga2 following a regular vim-icinga2 package installation solved the issue. The -w option forces a system wide rather than a just per current user activation. Notice that executing vim-addon-manager without arguments yields a list of 39 modes being disabled by default:

> vim-addon-manager
# Name                     User Status  System Status 
align                       removed       removed       
alternate                   removed       removed       
                        ...
icinga2                     removed       installed    # Due to above command
                        ...

If you do miss highlighting chances are your mode is among this list.

NB: Ubuntu 18.04 seemingly inherits Debian's policy. None of the above answers solved my issue. No ~/.vimrc configuration or manual activation was being required after the above described activation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top