This is just a tip for a few settings which may be handy if someone is hacking Fantom files with ViM as the editor defaults are not particulary friendly to Fantom Conventions.
Note that there is a Fantom syntax file in adm/tools/vim/ (it will be included with ViM 7.3). To let it load automatically in older versions one needs to edit filetype.vim from the ViM distribution and add this:
" Fantom
au BufNewFile,BufRead *.fan,*.fwt setf fan
Besides that I can recommend autoloading some settings. This can be done by putting this section to .vimrc:
if has("autocmd")
" Fantom *.fan and *.fwt files.
augroup fan
autocmd BufRead,BufNewFile *.fan source ~/.vimrc-fan
autocmd BufRead,BufNewFile *.fwt source ~/.vimrc-fan
augroup END
endif
and setting fantom defaults in .vimrc-fan. Here is a sample with a few useful macros:
set tabstop=2
set shiftwidth=2
set expandtab
set smartindent
set number
" section break
map ,s o<CR><Esc>75i/<Esc>o// Section<CR><Esc>75i/<Esc>o<Esc>2k3lcw
" new class break
map ,n o<CR><Esc>75i*<Esc>o** NewClass<CR><Esc>75i*<Esc>o<Esc>2k3lcw
" comment out visual block
vmap ,c "zd:set paste<CR>i/*<CR><C-R>z<Esc>:set nopaste<CR>O*/<Esc>
" uncomment /* and */ from the current block
nmap ,u mi?[\t ]*/*\*[\t ]*$<CR>%%dd''dd<CR>`i
" comment line or visual block
function! FanComment()
let hls=@/
s/^/\/\//
let @/=hls
endfunction
map <M-c> :call FanComment()<CR>
" uncomment line or visual block
function! FanUnComment()
let hls=@/
s/^\/\///
let @/=hls
endfunction
map <M-u> :call FanUnComment()<CR>
Any other Fantom related suggestions / links / macros are welcome.
dfreireWed 16 Jun 2010
now we're talking :-)
katoxTue 7 Sep 2010
Just a note: ViM 7.3 has been released. Besides the new cool feature of persistent undo it also handles Fantom source syntax by default. So should upcoming linux distros ;-).
katox Wed 16 Jun 2010
This is just a tip for a few settings which may be handy if someone is hacking Fantom files with ViM as the editor defaults are not particulary friendly to Fantom Conventions.
Note that there is a Fantom syntax file in
adm/tools/vim/
(it will be included with ViM 7.3). To let it load automatically in older versions one needs to editfiletype.vim
from the ViM distribution and add this:Besides that I can recommend autoloading some settings. This can be done by putting this section to
.vimrc
:and setting fantom defaults in
.vimrc-fan
. Here is a sample with a few useful macros:Any other Fantom related suggestions / links / macros are welcome.
dfreire Wed 16 Jun 2010
now we're talking :-)
katox Tue 7 Sep 2010
Just a note: ViM 7.3 has been released. Besides the new cool feature of persistent undo it also handles Fantom source syntax by default. So should upcoming linux distros ;-).