Re:Code Substitution Done Right - Switch.vim
by ktusznio on Wednesday September 12, 2012 @11:27AM
(#4511087)
This looks cool but I'd like filetype-independent definitions. For example, to convert a ruby dictionary pasted into a .js file.
[ Parent
| on HN ]
Re:Code Substitution Done Right - Switch.vim
by AndrewRadev on Wednesday September 12, 2012 @04:15PM
(#4512920)
Well, in your case, you could put a definition for javascript. The built-in "ruby hash style" transformation should work for this:
" in ftplugin/javascript.vim
let b:switch_definitions =
\ [
\ g:switch_builtins.ruby_hash_style
\ ]
With this, in a javascript file, you can turn ":foo => 'bar'" entries into "foo: 'bar'" ones.If you do need global (non-filetype) switches, you could define some by placing them in the g:switch_definitions variable. Read up on the docs if you want more information.