Install from a Zipball
This is the quickest way to get things running.
Download the latest zipball from [vim.org][zipball-vim] or github. The latest version on github is under Download Packages (don't use the Download buttons.)
Extract the archive into
unzip -od ~/.vim uniscript-vim-HASH.zip
These steps are also used to update the plugin.
Install with Pathogen
Since this plugin has rolling versions based on git commits, using pathogen and
git is the preferred way to install. The plugin ends up contained in its own
directory and updates are just a
git pull away.
Install tpope's pathogen into
~/.vim/autoload/and add this line to your
To get the all the features of this plugin, make sure you also have a
filetype plugin indent online in there.
Create and change into
$ mkdir ~/.vim/bundle $ cd ~/.vim/bundle
Make a clone of the
$ git clone https://github.com/kchmck/vim-coffee-script.git
$ cd ~/.vim/bundle/vim-coffee-script
Pull in the latest changes:
$ git pull
I'M NOT SURE HOW TO HANDLE THIS SECTION YET.
UniScriptMake command compiles the current file and parses any errors:
The full signature of the command is:
:[silent] UniScriptMake[!] [COFFEE-OPTIONS]...
UniScriptMake 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
UniScriptMake are passed along to
UniScriptMake 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 *.coffee silent UniScriptMake!
All of the customizations above can be used, too. This one compiles silently
and with the
-b option, but shows any errors:
au BufWritePost *.coffee silent UniScriptMake! -b | cwindow | redraw!
redraw! command is needed to fix a redrawing quirk in terminal vim, but
can removed for gVim.
Default compiler options
CoffeeMake command passes any options in the
variable along to the compiler. You can use this to set default options:
let coffee_make_options = '--bare'
Path to compiler
To change the compiler used by
coffee_compiler to the full path of an executable or the filename of one
let coffee_compiler = '/usr/bin/coffee'
This option is set to
coffee by default.
CoffeeCompile: Compile Snippets of CoffeeScript
CoffeeCompile command shows how the current file or a snippet of
:[RANGE] CoffeeCompile [watch|unwatch] [vert[ical]] [WINDOW-SIZE]
CoffeeCompile without a range compiles the whole file:
CoffeeCompile with a range, like in visual mode, compiles the selected
snippet of CoffeeScript:
This scratch buffer can be quickly closed by hitting the
vert splits the CoffeeCompile buffer vertically instead of horizontally:
coffee_compile_vert variable to split the buffer vertically by
let coffee_compile_vert = 1
The initial size of the CoffeeCompile buffer can be given as a number:
Watch (live preview) mode
Watch mode is like the Try CoffeeScript preview box on the CoffeeScript homepage:
watch to start watching a buffer (
vert is also recommended):
:CoffeeCompile watch vert
After making some changes in insert mode, hit escape and the CoffeeScript will
be recompiled. Changes made outside of insert mode don't trigger this recompile,
CoffeeCompile will compile these changes without any bad effects.
To get synchronized scrolling of a CoffeeScript and CoffeeCompile buffer, set
scrollbind on each:
unwatch to stop watching a buffer:
CoffeeLint: Lint your CoffeeScript
CoffeeLint command runs coffeelint (version
0.4.0 or later required) on the current file and parses any errors:
:[RANGE] CoffeeLint[!] [COFFEELINT-OPTIONS]
Use it like
Default coffeelint options
coffee_lint_options are passed along to
let coffee_lint_options = '-f lint.json'
coffee_linter option to set a different path to the
let coffee_linter = '/usr/bin/coffeelint'
This option is set to
coffeelint by default.
CoffeeRun: Run some CoffeeScript
CoffeeRun command compiles the current file or selected snippet and runs
Configure Syntax Highlighting
Add these lines to your
vimrc to disable the relevant syntax group.
Disable trailing whitespace error
Trailing whitespace is highlighted as an error by default. This can be disabled with:
hi link coffeeSpaceError NONE
Disable trailing semicolon error
hi link coffeeSemicolonError NONE
Disable reserved words error
Reserved words like
var are highlighted as an error where
they're not allowed in CoffeeScript. This can be disabled with:
hi link coffeeReservedError NONE
Tune Vim for CoffeeScript
Changing these core settings can make vim more CoffeeScript friendly.
Fold by indentation
Folding by indentation works well for CoffeeScript functions and classes:
To fold by indentation in CoffeeScript files, add this line to your
au BufNewFile,BufReadPost *.coffee 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 *.coffee setl foldmethod=indent
To get standard two-space indentation in CoffeeScript files, add this line to
au BufNewFile,BufReadPost *.coffee setl shiftwidth=2 expandtab