[20131125]使用vim做合计计算.txt
工作需要,需要使用vim做合计计算,把一列的数据累加,输出结果,到网站检索,发现:
http:///scripts/script.php?script_id=1932
visSum.vim插件比较合适.结果测试发现一些问题,结果自己花了一个下午晚上的时间测试修改,有点浪费时间.
主要原因:
1.不熟悉vim里面的函数,以及命令格式.
2.vim scripts 不知道如何调试,我最后只能单步跟踪执行.
3.作者使用折叠功能,自己还花一点时间学习这方面的知识.
最后脚本修改如下:
VimSum.vim脚本如下,点击(此处)折叠或打开
-
\" vim:filetype=vim foldmethod=marker textwidth=78
-
\" ==========================================================================
-
\" File: visSum.vim (global plugin)
-
\" Last Changed: 2012-07-17
-
\" Maintainer: Erik Falor
-
\" Version: 1.0
-
\" License: Vim License
-
\"
-
\" A great big thanks to Christian Mauderer for providing a patch for
-
\" floating-point support!
-
\"
-
\" ________ __ __
-
\" /_ __/ /_ ____ _____ / /_______/ /
-
\" / / / __ \\/ __ `/ __ \\/ //_/ ___/ /
-
\" / / / / / / /_/ / / / / ,< (__ )_/
-
\" /_/ /_/ /_/\\__,_/_/ /_/_/|_/____(_)
-
\"
-
\" This plugin will work whether or not your Vim is compiled with support for
-
\" floating-point numbers. If your Vim doesn\'t has(\'float\'), we\'ll just
-
\" ignore whatever comes after the decimal point.
-
\"
-
\" Due to the way Vim parses floating-point numbers, the only valid separtator
-
\" between the whole and fractional parts of the number is a period. Vim
-
\" won\'t accept a comma, even if that\'s your locale\'s preference. This
-
\" plugin follows that convention.
-
\" ==========================================================================
-
-
\" Exit quickly if the script has already been loaded
-
let s:this_version = \'1.0\'
-
if exists(\'g:loaded_visSum\') && g:loaded_visSum == s:this_version
-
finish
-
endif
-
let g:loaded_visSum = s:this_version
-
-
\"Mappings {{{
-
\" clean up existing key mappings upon re-loading of script
-
if hasmapto(\'SumNum\')
-
nunmap \\su
-
vunmap \\su
-
nunmap SumNum
-
vunmap SumNum
-
endif
-
-
\" Key mappings
-
nmap su SumNum
-
vmap su SumNum
-
-
if has(\'float\')
-
\" Call the floating-point version of the function
-
nmap