CSV.vim plugin has an ability to change the column deliminator/separator. I would like to find a plugin by which I can change all decimal points (such as comma) to dot, does there exist plugin to do such conversion?

P.s. This is the command that does this, :%s/\([0-9]\)\.\([0-9]\)/\1,\2/g, but I would like to find a plugin that brings this kind of common conversions as scripts.

  • 2
    For such a simple command, you don't need a plugin. – Christian Brabandt Jan 25 '17 at 17:38

Why don't you define a command from this line? Drop it in $HOME/.vim/plugin/yourpluginname.vim, and you're done. (at least, this is enough for something that simple)

command! -range=% ChangeDotToComa <line1>,<line2>s/\d\zs\.\ze\d/,/g

PS: Honestly, in that case, I'd rather change the locale of my machine to tell it that I want to use . as the decimal point and not ,. (But then I've troubles with CSV files produced by excel running with unmodified French locale. They are fortunately rare enough)

  • 2
    For a one liner like this one which isn't defined for a specific filetype, is there a reason to put it in a plugin rather than directly in the vimrc? – statox Jan 25 '17 at 14:38
  • 1
    @statox, Good question. Plugins can be easily installed/distributed, and potentially their maintenance can be centralized. For instance, one may want to use the character returned by locale -k decimal_point. If this was a distributed plugin, everyone could take advantage of it. Now ... is this the reason why the OP asked for a plugin? I don't know. – Luc Hermitte Jan 25 '17 at 15:44
  • 1
    My mistake. I've fixed the path of the file. Files under $HOME/.vim/plugin are automatically loaded. Those under $HOME/.vim/aren't. – Luc Hermitte Jan 25 '17 at 22:13
  • Does every file.vim in .vim folder get automatically loaded? – hhh Jan 26 '17 at 7:19
  • I've answered your question in the comment that precedes it. – Luc Hermitte Jan 26 '17 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.