ITPub博客

首页 > Linux操作系统 > Linux操作系统 > [20131125]使用vim做合计计算.txt

[20131125]使用vim做合计计算.txt

原创 Linux操作系统 作者:lfree 时间:2013-11-25 08:59:55 0 删除 编辑
[20131125]使用vim做合计计算.txt

工作需要,需要使用vim做合计计算,把一列的数据累加,输出结果,到www.vim.org网站检索,发现:

http://www.vim.org/scripts/script.php?script_id=1932

visSum.vim插件比较合适.结果测试发现一些问题,结果自己花了一个下午晚上的时间测试修改,有点浪费时间.
主要原因:
1.不熟悉vim里面的函数,以及命令格式.
2.vim scripts 不知道如何调试,我最后只能单步跟踪执行.
3.作者使用折叠功能,自己还花一点时间学习这方面的知识.

最后脚本修改如下:

VimSum.vim脚本如下,点击(此处)折叠或打开

  1. \" vim:filetype=vim foldmethod=marker textwidth=78
  2. \" ==========================================================================
  3. \" File: visSum.vim (global plugin)
  4. \" Last Changed: 2012-07-17
  5. \" Maintainer: Erik Falor
  6. \" Version: 1.0
  7. \" License: Vim License
  8. \"
  9. \" A great big thanks to Christian Mauderer for providing a patch for
  10. \" floating-point support!
  11. \"
  12. \" ________ __ __
  13. \" /_ __/ /_ ____ _____ / /_______/ /
  14. \" / / / __ \\/ __ `/ __ \\/ //_/ ___/ /
  15. \" / / / / / / /_/ / / / / ,< (__ )_/
  16. \" /_/ /_/ /_/\\__,_/_/ /_/_/|_/____(_)
  17. \"
  18. \" This plugin will work whether or not your Vim is compiled with support for
  19. \" floating-point numbers. If your Vim doesn\'t has(\'float\'), we\'ll just
  20. \" ignore whatever comes after the decimal point.
  21. \"
  22. \" Due to the way Vim parses floating-point numbers, the only valid separtator
  23. \" between the whole and fractional parts of the number is a period. Vim
  24. \" won\'t accept a comma, even if that\'s your locale\'s preference. This
  25. \" plugin follows that convention.
  26. \" ==========================================================================
  27. \" Exit quickly if the script has already been loaded
  28. let s:this_version = \'1.0\'
  29. if exists(\'g:loaded_visSum\') && g:loaded_visSum == s:this_version
  30. finish
  31. endif
  32. let g:loaded_visSum = s:this_version
  33. \"Mappings {{{
  34. \" clean up existing key mappings upon re-loading of script
  35. if hasmapto(\'SumNum\')
  36. nunmap \\su
  37. vunmap \\su
  38. nunmap SumNum
  39. vunmap SumNum
  40. endif
  41. \" Key mappings
  42. nmap su SumNum
  43. vmap su SumNum
  44. if has(\'float\')
  45. \" Call the floating-point version of the function
  46. nmap
请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    2458
  • 访问量
    6262507