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

lfree發表於2013-11-25
[20131125]使用vim做合計計算.txt

工作需要,需要使用vim做合計計算,把一列的資料累加,輸出結果,到網站檢索,發現:

http:///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
[20131125]使用vim做合計計算.txt
請登入後發表評論 登入
全部評論

相關文章