Editing Vim
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
[http://www.vim.org/ Vim the editor] is one of the most famous text editors in the hacker programming universe. It has a plenty of extensible (script-based) capabilities and very comfortable shortcuts that makes the programmer the fastest gun of the old west. (I can imagine Vim in front of Emacs on a desert city, Vim's shot is much faster!). In this page you'll learn some tips to better adapt Vim for GNU Octave programming. | [http://www.vim.org/ Vim the editor] is one of the most famous text editors in the hacker programming universe. It has a plenty of extensible (script-based) capabilities and very comfortable shortcuts that makes the programmer the fastest gun of the old west. (I can imagine Vim in front of Emacs on a desert city, Vim's shot is much faster!). In this page you'll learn some tips to better adapt Vim for GNU Octave programming. | ||
If you aren't familiar with Vim script language, you can also use [http://brainacle.com/how-to-write-vim-plugins-with-python.html Python to write Vim plugins]. If you do some for GNU Octave, please let us | If you aren't familiar with Vim script language, you can also use [http://brainacle.com/how-to-write-vim-plugins-with-python.html Python to write Vim plugins]. If you do some for GNU Octave, please let us now. | ||
== Vim as the default editor == | == Vim as the default editor == | ||
To set Vim as the default editor launched by the GNU Octave {{Codeline|edit}} command, add | To set Vim as the default editor launched by the GNU Octave {{Codeline|edit}} command, add the following line to your {{Path|~/.octaverc}} file: | ||
edit mode async | |||
and one of the following: | |||
edit editor "<terminal> -e 'vim %s'" | |||
edit editor "gvim %s" | |||
where {{Codeline|<terminal>}} can be [http://directory.fsf.org/wiki/Gnome-terminal gnome-terminal], [http://directory.fsf.org/wiki/Xterm xterm], or any other terminal of your preference. Please note the {{Codeline|-e}} option is common to the mentioned terminals, change it if necessary. | |||
== A better GNU Octave syntax file == | == A better GNU Octave syntax file == | ||
As for now, Vim hasn't a dedicated, officially distributed filetype for GNU Octave. The community agreed the best solution is to use [http://www.vim.org/scripts/script.php?script_id=3600 octave.vim] by Rik. All the instructions for installing it can be found on the hyperlink. | |||
== Accessing GNU Octave info == | == Accessing GNU Octave info == | ||
GNU Octave info package can be found in almost all Linux distributions. | GNU Octave info package can be found in almost all Linux distributions. For installing it under Ubuntu, you can type: | ||
$ sudo apt-get install octave<version>-info | $ sudo apt-get install octave<version>-info | ||
where {{Codeline|<version>}} must be substituted by the appropriate string. | where {{Codeline|<version>}} must be substituted by the appropriate string. Add the following line to your {{Path|~/.vimrc}} file: | ||
Add the following line to your {{Path|~/.vimrc}} file: | |||
autocmd FileType matlab setlocal keywordprg=info\ octave\ --vi-keys\ --index-search | autocmd FileType matlab setlocal keywordprg=info\ octave\ --vi-keys\ --index-search | ||
Line 40: | Line 30: | ||
Now, when editing a {{Path|*.m}} file, you can type {{Key|K}} in normal mode and the word under the cursor will be searched for in the GNU Octave documentation index. Pressing {{Key|,}} yields the next occurrence. | Now, when editing a {{Path|*.m}} file, you can type {{Key|K}} in normal mode and the word under the cursor will be searched for in the GNU Octave documentation index. Pressing {{Key|,}} yields the next occurrence. | ||
'''OBS:''' If using the Rik's [http://www.vim.org/scripts/script.php?script_id=3600 octave.vim] syntax, replace {{Codeline|matlab}} by {{Codeline|octave}}. | |||
''' | |||
== Jumping between control statements == | == Jumping between control statements == | ||
Line 68: | Line 45: | ||
\ s:conditionalEnd . ',\<if\>:\<elseif\>:\<else\>:' . s:conditionalEnd | \ s:conditionalEnd . ',\<if\>:\<elseif\>:\<else\>:' . s:conditionalEnd | ||
It allows to jump (quasi-)correctly even in the presence of array indexing with {{Codeline|end}}. | It allows to jump (quasi-)correctly even in the presence of array indexing with {{Codeline|end}}. Put the cursor on an {{Codeline|if}} keyword for example and press {{Key|%}}, it'll move to the corresponding {{Codeline|elseif}}, {{Codeline|else}}, {{Codeline|end}} keywords. | ||
Any improvements on the {{Codeline|b:match_words}} variable are welcome. | Any improvements on the {{Codeline|b:match_words}} variable are welcome. | ||