Vim
Revision as of 11:43, 7 August 2011 by UnsafePerformIO (talk | contribs)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
This page intended Haskell vim-users.
Plugins
Put code in file ~/.vim/plugin/Haskell.vim
, or in multiple files in that directory.
Module Sections
The following code prompts for a name, and places a section with that name at current position, when key sequence "--s":
let s:width = 80 function! HaskellModuleSection(...) let name = 0 < a:0 ? a:1 : inputdialog("Section name: ") return repeat('-', s:width) . "\n" \ . "-- " . name . "\n" \ . "\n" endfunction nmap <silent> --s "=HaskellModuleSection()<CR>gp
Like so:
--------------------------------------------------------------------------------
-- my section
Module Headers
The following code prompts for module name, a note, a description of module, and places a module comment at top, when key sequence "--h":
let s:width = 80 function! HaskellModuleHeader(...) let name = 0 < a:0 ? a:1 : inputdialog("Module: ") let note = 1 < a:0 ? a:2 : inputdialog("Note: ") let description = 2 < a:0 ? a:3 : inputdialog("Describe this module: ") return repeat('-', s:width) . "\n" \ . "-- | \n" \ . "-- Module : " . name . "\n" \ . "-- Note : " . note . "\n" \ . "-- \n" \ . "-- " . description . "\n" \ . "-- \n" \ . repeat('-', s:width) . "\n" \ . "\n" endfunction nmap <silent> --h "=HaskellModuleHeader()<CR>:0put =<CR>
like so:
--------------------------------------------------------------------------------
-- |
-- Module : MyModule
-- Note : This is a preview
--
-- This is an empty module, to show the headercomment produced.
--
--------------------------------------------------------------------------------