SCVim with Auto completion and Snippets

The nicest part of using vim for me is to use the window management. It gives an opportunity to work in a clean environment that windows are not floating around, no need to search for a window behind another.

The second part that I discovered is to use all the functionality on Vim. I love vim more and more everyday. At the beginning, it was too difficult to know all the shorcuts and function keys, but after some time forcing myself to use them more and more and putting some ‘postits’ with some cheat-notes on the frame of my monitor, I think it is a powerful tool.

I would like to introduce some of powerful sides of using vim for SuperColliding. (it works in both Linux and OSX)

Snippets

I use the snippet plugin that you can download from vim website. It is called ‘snipMate‘ and you can also see the screencast.

Download the zip file into ~/.vim and unzip it, then you can find ‘snippets’ folder too. There, you can create your own snippets for any language (that vim supports) you are using.

Here, since I installed scvim, I will give you an example of how this snippets work.

Create a file on ~/.vim/snippets/supercollider/example.snippet
The file name is an important element because you are going to call the snippet with the file name.
In this case, when you edit vim, you are going to write ‘example’ and then tab key.
Here I will write a SynthDef snippet since I make SynthDef a lot.

Here is the example.

(
  SynthDef("${1:synthname}",
  {
  arg ${2:arg1};
  var ${3:var1};
  $3 = ${4:write};
  Out.ar(${5:outbus},${6:output})
  }).store;
 )

In this way, you created a snippet. I named it as ‘syndef’

When you call, you will see this

Because we setup the synth name as an argument by doing ${number:name}, your cursor will stop at the first argument.
After you fill up the synth name, and click ‘TAB’ button, then it will move to the second argument, in this case ‘arg1.’

The best part of this is that the name of argument becomes flexible. In this example, ‘var1’ is used in two places. If you fix one of ‘var1’ name, then the other one will follow. You don’t need to go down to the name and try to fix it!!

This is a simple example. I don’t use a lot of snippet, but some that save lots of time for me.

 

Auto Completion

For auto completion, I use ‘AutoComplPop‘ plugin.

If you have installed correctly, you will find those files ‘sc_object_completion’ and ‘supercollider_objects.vim.’ in ~/.scvim folder. Those files are going to be used to create auto completion.
If you don’t get itย successfully, copy those two files into ~/.vim folder. Then when you type in, you will see this :

That’s quite easy!!

I am still exploring what could be useful for coding. I will post when I discover something useful. Hope you enjoy!

2 Comments

  1. Hello there ๐Ÿ™‚

    I am trying to get autocompletion to work. Got really jealous with the new feautures of the IDE but I can not be away from Vim.. I tried you instruction but where can I find sc_object_completion? And how do you keep this files up to date?

    Thanks!!

  2. Hi. If you are downloading your SC3 sources, you will always have the up-to-date file. The sc_object_completion file is in ~/.scvim folder as I posted. Recently I moved to Emacs. Don’t know if it’s still in that folder, but very possibly.

Leave a Comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.