Vim脚本之Haskell卷

    技术2022-05-20  51

    最近常写Haskell代码, 苦于vim本身ftplugin除了语法加亮处没什么特別的功能。 深感其縮进功能欠佳。在其它语言中用Tab, >>, << 习惯了(我是TAB派的,讨厌空格作缩进)。 Haskell虽是缩进决定結构的,但不像Python,TAB作缩进将会变得很hässlich(貌似ghc本身的代码里也有许多Tab?)。 故自己写了一些脚本,使TAB不再是制表符,两是智能的缩进。先写这么多,明天再加其它feature autocmd  FileType  haskell call  HaskellMode() function  HaskellMode()         "set shiftwidth=1         set  autoindent         set  tabstop =8         set  expandtab         imap  < silent > < TAB >  < C-R > =HaskellTab()< CR >         "map o o<TAB>         "map O O<TAB>         call  matchadd ( "ERROR" , " // t" ) endfunction function  HaskellTab()         if  line ( "." )  ==  1                 return  ""         endif         let  letzte_zeile =  getline ( line( "." )  -  1 )         let  cursor_spalt =  virtcol ( "." )         let  springen_nach =  matchend ( letzte_zeile, "[ // t] // +" , cursor_spalt)           if  springen_nach <=  cursor_spalt                 "" schon am rechten Rand                 return  ""         else                 return  repeat ( " " , 1  +  springen_nach -  cursor_spalt)         endif endfunction

    [ 本帖最后由 wuchuanren 于 2009-10-18 21:02 编辑 ]

    http://www.2plus3.eu/redirect.php?fid=22&tid=2453&goto=nextnewset


    最新回复(0)