Installing and Using
Be aware that it must be added before any
filetype plugin indent onlines according to the install page:
Note that you need to invoke the pathogen functions before invoking "filetype plugin indent on" if you want it to load ftdetect files. On Debian (and probably other distros), the system vimrc does this early on, so you actually need to "filetype off" before "filetype plugin indent on" to force reloading.
Create, and change into, the
$ mkdir -p ~/.vim/bundle $ cd ~/.vim/bundle
Make a clone of the
$ git clone git://github.com/satyr/vim-coco.git [...] $ ls vim-coco/
That's it. Pathogen should handle the rest. Opening a file with a
extension or a
Cokefile will load everything.
Change into the
$ cd ~/.vim/bundle/vim-coco
Pull in the latest changes:
$ git pull
Everything will then be brought up to date.
CocoMake: Compile the Current File
CocoMake command compiles the current file and parses any errors.
The full signature of the command is:
:[silent] CocoMake[!] [co-OPTIONS]...
CocoMake shows all compiler output and jumps to the first line
reported as an error by
Compiler output can be hidden with
Line-jumping can be turned off by adding a bang:
Options given to
CocoMake are passed along to
CocoMake can be manually loaded for a file with:
Recompile on write
To recompile a file when it's written, add an
autocmd like this to your
au BufWritePost *.co silent CocoMake!
All of the customizations above can be used, too. This one compiles silently
and with the
-b option, but shows any errors:
au BufWritePost *.co silent CocoMake! -b | cwindow | redraw!
redraw! command is needed to fix a redrawing quirk in terminal vim, but
can removed for gVim.
Default compiler options
CocoMake command passes any options in the
variable along to the compiler. You can use this to set default options:
let co_make_options = '--bare'
Path to compiler
To change the compiler used by
co_compiler to the full path of an executable or the filename of one
let co_compiler = '/usr/bin/coco'
This option is set to
coco by default.
CocoCompile: Compile Snippets of Coco
CocoCompile command shows how the current file or a snippet of
:[RANGE] CocoCompile [watch|unwatch] [vert[ical]] [WINDOW-SIZE]
CocoCompile without a range compiles the whole file.
CocoCompile with a range, like in visual mode, compiles the selected
snippet of Coco.
The scratch buffer can be quickly closed by hitting the
vert splits the CocoCompile buffer vertically instead of horizontally:
co_compile_vert variable to split the buffer vertically by
let co_compile_vert = 1
The initial size of the CocoCompile buffer can be given as a number:
Watch (live preview) mode
watch to start watching a buffer (
vert is also recommended):
:CocoCompile watch vert
After making some changes in insert mode, hit escape and your code will
be recompiled. Changes made outside of insert mode don't trigger this recompile,
CocoCompile will compile these changes without any bad effects.
To get synchronized scrolling of a Coco and CocoCompile buffer, set
scrollbind on each:
unwatch to stop watching a buffer:
Tune Vim for Coco
Changing these core settings can make vim more Coco friendly.
Fold by indentation
Folding by indentation works well for Coco functions and classes.
To fold by indentation in Coco files, add this line to your
au BufNewFile,BufReadPost *.co setl foldmethod=indent nofoldenable
With this, folding is disabled by default but can be quickly toggled per-file
zi. To enable folding by default, remove
au BufNewFile,BufReadPost *.co setl foldmethod=indent
To get standard two-space indentation in Coco files, add this line to
au BufNewFile,BufReadPost *.co setl shiftwidth=2 expandtab