<

c s o u n d   v i m   r e a d m e

version and date: see csound.vim
synchronized with Csound version: see csound_opcodes.vim
author: luis jure
e-mail: lj@eumus.edu.uy




c o l o r   h i g h l i g h t i n g   ( : s y n   o n )

Recognition and color highlighting of the lexical elements of different programming languages is one of the "improvements" of Vim over old Vi.

Syntax recognition is activated within Vim with the command:

:sy[n[t[a[x]]]]] on

(Vim is not very choosy!!)

You may want to have it always activated, so it's more practical to include that line either in the global vimrc (it can be found in /etc/vimrc or $VIM/vimrc and will take effect to all users in your system), or in your personal .vimrc file in your home directory. If you don't have such a file, simply create one with that line only, although it's strongly suggested that you take a closer look at all the options you can set with vimrc, specially if you are a frequent Vim user. In the Vim package you can find some sample configuration files.

If Vim complains that the command is unknown or not available, it may have been built without the syntax option. Check with :version all the options Vim was compiled with; you should see +syntax, otherwise you may have to recompile Vim.

If you work in a console you may need to invoke Vim with the option -T xterm in order to have colors available. You can also include this in vimrc, with the line:

:set term=xterm


s y n t a x   d e f i n i t i o n s   ( c s o u n d . v i m )

Vim installs the files with lexical definitions for different languages in the directory $VIMRUNTIME/syntax (for version 5.4 and newer) or $VIM/syntax (in older versions). These variables need not be set anywhere; Vim usually takes as a default /usr/[local/]share/vim/ and /usr/[local/]share/vim/vimXX respectively, where XX is the version number. Try :echo $VIMRUNTIME or :echo $VIM within Vim.

Configuration files have the extension .vim; first thing is to copy csound.vim and csound_opcodes.vim to the $VIM[RUNTIME]/syntax directory.

In an open file you can instruct Vim to load csound.vim by typing:

:so $VIMRUNTIME/syntax/csound.vim

But it's more practical automate the process adding the following line to vimrc or .vimrc:

au BufNewFile,BufRead *.orc,*.sco,*.csd      so $VIMRUNTIME/syntax/csound.vim

This way you'll have automatic recognition of csound files by the extensions .orc, .sco, or .csd. (whether you open an existing file or create a new one.)


l i s t   o f   o p c o d e s   ( c s o u n d _ o p c o d e s . v i m )

In order to make it easier to maintain, the list of opcodes that will be recognized by Vim is kept in a separate file, called csound_opcodes.vim (the idea was taken from Istvan Varga). I try to keep this file up to date with the opcodes in the latest canonical version maintained by John ffitch, but you can update it yourself or adapt it to the version of Csound you are using. Running csound -z lists all the opcodes available in your version of Csound. You can pipe the output to a file, and editing accordingly use it as csound_opcodes.vim, the format of which is very simple.

Or you can try this bash script that automates the process using sed, leaving a csound_opcodes.vim file in your working directory. You only need to copy it as root to $VIMRUNTIME/syntax/.


m a c r o   k e y s   ( c s o u n d _ m a c r o s . v i m )

Following suggestions and ideas contributed by Jay Chernick, I wrote a set of macros for operations like compiling the file you are editing, and playing the last audio file created by Csound. These macros are mapped to function keys <F9> to <F12>, so that you can test your Csound files and listen to the results with a single-key stroke, without leaving the editor.

Originally the macros were included in the syntax file csound.vim itself, but it has been rightly noted (by Frank Barknecht) that they don't belong to a syntax file and should go somewhere else. So I created a different file called csound_macros.vim and put it in the folder Vim reserves for macros.

First, copy csound_macros.vim to $VIMRUNTIME/macros/ ($VIM/macros/ in older versions of Vim).

Then declare it adding this line in vimrc:

au BufNewFile,BufRead *.csd      so $VIMRUNTIME/macros/csound_macros.vim

The macros work only for files in csd format, and this way they will be loaded every time you open an existing .csd file or create a new one.

These macros were designed for GNU/Linux, I don't know how to make something similar in other operating systems. Their functions are:

Obviously, these macros won't necessarily work in your environment as they are, you'll have to check flags, paths, file formats, command names, etc.


o n - l i n e   m a n u a l

Vim has a help system, with which you can browse the manual on-line. Typing :help (or simply :he) will open an additional window with the complete Vim reference manual. You can then navigate through it following the highlighted |tags|, see the :help entry for more details.

Since version 6, Vim allows the user to add new help files. Log in as root, and copy the csound.txt file (you may need to uncompress it first) to $VIMRUNTIME/doc. Then register the new tags, running the following command from within Vim:

:helptags $VIMRUNTIME/doc

Please note that this command is only available since Vim version 6.

:he csound opens the help window at the top of the manual; once there you can navigate in the usual ways.
:he oscil, or any other opcode name, will jump directly to the manual entry for that opcode.
placing the cursor on an opcode name and typing K in normal, mode will also jump directly to the corresponding manual entry.


t e m p l a t e s

If you want to have templates for .csd and .orc files, create a directory $VIMRUNTIME/templates and put there template.csd and template.orc; then you should add another line to vimrc:

au BufNewFile *.csd     0r $VIMRUNTIME/templates/template.csd
au BufNewFile *.orc     0r $VIMRUNTIME/templates/template.orc

(that's a "zero", not "oh")

Now if you create a new file with the extension .csd or .orc, Vim will use the respective template. You can easily edit them to suit your preferences, and create your own template for .sco files. You have to declare it the same way, of course.


c o n f i g u r i n g   c o l o r s

In csound.vim different types of lexical elements are defined, which are linked to default highlight groups set in syncolor.vim (older versions of Vim had color definitions in synload.vim or even syntax.vim). There are many ways you can change the colors to suit your tastes:

1) link to some other default groups
2) change the settings of these groups editing syncolor.vim
3) redefine these settings in vimrc, which will override the latter
4) instead of linking, set the attributes for each group directly in csound.vim


l a s t   w o r d

I'm not a Vim expert or anything, it's just that since Vim had no syntax recognition files for Csound, I had no other choice than trying to make my own. The first version was written in April 2000, taking the few things I was able to figure out from other .vim files, and the very little I could understand reading the documentation. It was rather basic and I guess somewhat crudely written, but I considered it usable and much better than nothing, so I made it available.

I have expanded and improved these files since then, and by now I think they are quite decent. In the meantime two csounders -Frank Barknecht and Istvan Varga- produced their respective csound.vim files. Reading and analysing their work helped me a lot to improve mine; you'll find many lines taken and adapted from their files here. My recognition to both.

I would greatly appreciate suggestions (and help!) to improve csound.vim. Specially if you find some Csound lexical elements that are not recognized (I don't use or even know them all!) and you think they should, drop me a line.

I would like to thank Dave Phillips and Nicola Bernardini for their help and encouragement, and for testing my first efforts.
Thanks also to Jay Chernik for contributing with ideas on how to map function-keys to macros.
Special thanks to Kevin Conder not only for allowing me to use his excellent Alternative Csound Reference Manual, but also for providing a one-page version of the html manual just to make my life easier.


< última actualización: 2003-07-27