Syntax Highlighting vi editor

8,080

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
Share:
8,080

Related videos on Youtube

Kaushal
Author by

Kaushal

Updated on September 18, 2022

Comments

  • Kaushal
    Kaushal over 1 year

    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 [email protected]
    Compiled by [email protected]
    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
    
    • muru
      muru about 7 years
      Looks like you're using vim-tiny (and the version output says -syntax). Which distro?
    • Mancubus
      Mancubus about 7 years
      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.
    • Kaushal
      Kaushal about 7 years
      @muru I am using ubuntu 16.10
  • muru
    muru about 7 years
    You don't need to purge tiny. All the other Vim versions have higher precedence and become vim
  • Chai T. Rex
    Chai T. Rex about 7 years
    OK, I've changed it to not include that.
  • SDsolar
    SDsolar almost 7 years
    How does it know which language to highlight? For instance, python
  • SilverWolf
    SilverWolf about 5 years
    @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!