sponsor Vim development Vim logo Vim Book Ad

octave.vim : Syntax highlighting file for GNU Octave language

 script karma  Rating 271/121, Downloaded by 10079  Comments, bugs, improvements  Vim wiki

created by
Rik ***
script type
This file provides syntax highlighting for the GNU Octave programming language.

* Highlights entire Octave grammar (endwhile, endfor, etc.), not just Matlab keywords
* Updated to highlight all core Octave functions as of version 4.2.0
* Highlights user functions and anonymous functions [@(...)] from within the .m file being edited
* Use-dependent highlighting of Octave system variables
   When querying system variables, keyword is highlighted as a constant.  For example, var = true, highlights 'true' as a constant.
   When setting variables or otherwise invoking keyword as a function, keyword is highlighted as a function.  For example, var = true (2,4), highlights 'true' as a function.
* Support for multi-line strings with line continuation characters as well as escaped quotes (\" or \') within string.
* Support for multi-line block comments
* Support for highlighting numbers that use hex (0x) or binary (0b) syntax
* Error highlighting for bad number syntax, bad structure variable names, bad block comments, bad line continuations.
* Optional support for highlighting operators (+, -, *, etc.), user variables, or tabs  

* Occasionally anonymous functions are highlighted as a function even though the instance is of the name as a variable.  This is too difficult to correct without writing a full parser.

* The syntax file has a list of every valid function in Octave which makes it useful as an auto-completion dictionary for use with ViM's omnifunc function.  Once installed, type a few letters of the name of a function and then use Ctrl-X Ctrl-O to bring up a list of possible matches.


This script owes some debt to the two existing Octave syntax scripts:

However, it has been thoroughly rewritten and expanded considerably.
install details
Syntax file install on a UNIX-like system

1) mkdir -p ~/.vim/syntax
2) cp octave.vim ~/.vim/syntax/
3) Add the following lines to your ~/.vimrc to get ViM to use the file

----- SNIP -----
" Octave syntax
augroup filetypedetect
  au! BufRead,BufNewFile *.m,*.oct set filetype=octave
augroup END
----- SNIP -----

Optional highlighting of operators (+, -, *, etc.), user variables, or tabs can be had by uncommenting the appropriately tagged lines in octave.vim.

OMNIFUNC install on a UNIX-like system

1) Install the syntax file as described above
2) Add the following lines to your ~/.vimrc after the snippet from step 3 above
----- SNIP -----
" Use keywords from Octave syntax language file for autocomplete
if has("autocmd") && exists("+omnifunc")
   autocmd Filetype octave
   \ if &omnifunc == "" |
   \ setlocal omnifunc=syntaxcomplete#Complete |
   \ endif
----- SNIP -----

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
octave.vim.4.2.0 4.2.0 2016-11-14 5.7 Rik *** Updated to include syntax highlighting for all functions in 4.2.0.
Highlights numbers that use new syntax for hex (0x) and binary (0b).
Classdef keywords now automatically indent/exdent when used in code.
octave.vim 3.8.3 2014-09-18 5.7 Rik *** Correctly highlight cell arrays that use a transpose operator
octave.vim 3.8.0 2014-01-10 6.0 Rik *** Updated function list to match 3.8.0 release of Octave
Correct coloring problem with escaped double quotes within double-quoted string
octave.vim 3.6.0b 2012-01-30 5.7 Rik *** Correctly highlight functions like strcmp which use '=' within quotes rather than assignment
octave.vim 3.6.0 2012-01-23 5.7 Rik *** Update with list of 3.6.0 functions.  Now highlights keywords varargin, varargout, parfor.
octave.vim 3.4.3 2011-10-12 5.7 Rik *** Updated for 3.4.3
Spellchecking in Vim, if used, is now restricted to string literals and comments which reduces screen clutter.
octave.vim 3.4.2 2011-08-03 5.7 Rik *** Updated with 3.4.2 function list
octave.vim 3.4.0c 2011-06-08 5.7 Rik *** Now highlights anonymous functions.
Commands integrated into use-dependent highlighting.
Better recognition of keyword on LHS of '=' to stop highlighting user variables
octave.vim 3.4.0b 2011-05-31 5.7 Rik *** Correct occasional non-highlighting of nested () within function calls
octave.vim 3.4.0 2011-05-24 5.7 Rik *** Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
OSDN.net Logo