4

This question already has an answer here:

How to enable syntax highlighting features in vi editor ? I am currently using ubuntu 16.10.

Here is the output of vi --version.

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 22:32:42)
Included patches: 1-1829
Extra patches: 8.0.0056
Modified by pkg-vim-maintainers@lists.alioth.debian.org
Compiled by pkg-vim-maintainers@lists.alioth.debian.org
Small version without GUI.  Features included (+) or not (-):
+acl             -farsi           -mouse_sgr       -tag_any_white
-arabic          -file_in_path    -mouse_sysmouse  -tcl
-autocmd         -find_in_path    -mouse_urxvt     -termguicolors
-balloon_eval    -float           -mouse_xterm     +terminfo
-browse          -folding         +multi_byte      -termresponse
+builtin_terms   -footer          -multi_lang      -textobjects
-byte_offset     +fork()          -mzscheme        -timers
-channel         -gettext         -netbeans_intg   -title
-cindent         -hangul_input    +packages        -toolbar
-clientserver    +iconv           -path_extra      -user_commands
-clipboard       -insert_expand   -perl            +vertsplit
-cmdline_compl   -job             -persistent_undo -virtualedit
+cmdline_hist    +jumplist        -printer         +visual
-cmdline_info    -keymap          -profile         -visualextra
-comments        -langmap         -python          -viminfo
-conceal         -libcall         -python3         -vreplace
-cryptv          -linebreak       -quickfix        +wildignore
-cscope          -lispindent      -reltime         -wildmenu
-cursorbind      -listcmds        -rightleft       +windows
-cursorshape     -localmap        -ruby            +writebackup
-dialog          -lua             -scrollbind      -X11
-diff            -menu            -signs           +xfontset
-digraphs        -mksession       -smartindent     -xim
-dnd             -modify_fname    -startuptime     -xsmp
-ebcdic          -mouse           -statusline      -xterm_clipboard
-emacs_tags      -mouse_dec       -sun_workshop    -xterm_save
-eval            -mouse_gpm       -syntax          -xpm
+ex_extra        -mouse_jsbterm   -tag_binary      
-extra_search    -mouse_netterm   -tag_old_static  
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -Wdate-time  -g -O2 -fdebug-prefix-map=/build/vim-vY1bx1/vim-7.4.1829=. -fPIE -fstack-protector-strong -Wformat -Werror=format-security -DTINY_VIMRC -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim    -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo  -lselinux -lacl -lattr -ldl 

I have tried :syntax on. Below is the error message of :syntax on

E319: Sorry, the command is not available in this version

marked as duplicate by muru, karel, Zanna, Eric Carvalho, George Udosen Feb 21 '17 at 17:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Looks like you're using vim-tiny (and the version output says -syntax). Which distro? – muru Feb 21 '17 at 3:38
  • Do you use correct heading and extension for a file? Make sure that a code starts with #!/bin/bash or #!/usr/bin/python or .... and file has proper extension. – Mancubus Feb 21 '17 at 3:43
  • @muru I am using ubuntu 16.10 – Kaushal Feb 21 '17 at 3:46
10

As muru points out, it looks like you're using the vim-tiny package. A more featureful Vim without a GUI can be found in either:

  • the vim package, with which you can't script Vim itself with external scripting languages
  • the vim-nox package, with which you can script Vim itself with external scripting languages

To install one, use either:

sudo apt install vim

Or:

sudo apt install vim-nox
  • 1
    You don't need to purge tiny. All the other Vim versions have higher precedence and become vim – muru Feb 21 '17 at 4:05
  • 1
    OK, I've changed it to not include that. – Chai T. Rex Feb 21 '17 at 4:11
  • 1
    How does it know which language to highlight? For instance, python – SDsolar Jun 8 '17 at 6:22
  • @SDsolar It uses a combination of filename matching (e.g. ".js" means it's probably a JavaScript file) and scripting for when that doesn't work (e.g. shell scripts often don't have extensions, and there are several different types). See :help filetype, and :help ftdetect in particular, for more information on this! – SilverWolf Mar 20 at 21:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.