Skip to content

Comment on Code Substitution Done Right - Switch.vimparent

Comments

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.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.