maksimr / vim-jsbeautify

vim plugin which formated javascript files by js-beautify
758 stars 68 forks source link

Provide an option for operator keybindings #88

Open yarray opened 9 years ago

yarray commented 9 years ago

Hi,

Recently I find the RangeJsBeautify() function and it's really handy. However, I think it may even be nicer if we can bind an operator on it. Basically what I want is to map "=" to the ranged beautifier instead of (broken) js indenter:

  1. When press == current line is formatted, just like calling RangeJsBeautify when selecting current line.
  2. When press =2j current line with next 2 lines will be formatted.
  3. When visual select some text and press =, the part will be formatted.

Currently 3 needs just a key binding. 1 and 2 are a little tricky. I'm trying to use operatorfunc and g@ in my vimrc but haven't got it to work since I'm not very familiar with vimscript. Is it possible to add an option like g:js_beautify_omap_key so that I can just add

let g:js_beautify_omap_key = '='

to my vimrc? Or offering a variation of RangeJsBeautify() which is compatible with operatorfunc is equally good.

maksimr commented 9 years ago

@yarray Thanks! Need investigation