Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim Syntax Highlighting does not work

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?

like image 389
Gilad Naaman Avatar asked Nov 03 '13 15:11

Gilad Naaman


People also ask

How do I enable syntax highlighting in vim?

After opening login.sh file in vim editor, press ESC key and type ':syntax on' to enable syntax highlighting. The file will look like the following image if syntax highlighting is on. Press ESC key and type, “syntax off” to disable syntax highlighting.

Does vim support syntax highlighting?

VIM is an alternative and advanced version of VI editor that enables Syntax highlighting feature in VI. Syntax highlighting means it can show some parts of text in another fonts and colors. VIM doesn't show whole file but have some limitations in highlighting particular keywords or text matching a pattern in a file.

How do I highlight in vim editor?

Press 1 to highlight the current visually selected text, or the current word (if nothing is selected). Highlight group hl1 is used. Press 2 for highlight hl2 , 3 for highlight hl3 , etc. Press 0 to remove all highlights from the current visually selected text, or the current word.

How do I highlight a line in vim?

If you want to select the entire line in a file, press V. Now when you press k or j to go up and down, vim will select the entire line above and below your cursor.


2 Answers

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

filetype plugin on syntax on 
like image 122
Gaurav Avatar answered Sep 24 '22 18:09

Gaurav


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.

like image 24
romainl Avatar answered Sep 24 '22 18:09

romainl