vim-endwise icon indicating copy to clipboard operation
vim-endwise copied to clipboard

Request for javascript? :D

Open pheze opened this issue 14 years ago • 8 comments

$('bleh').click(function() { |(cursor here) , possibility to add missing ; ? })

pheze avatar Feb 10 '11 18:02 pheze

Cool though this may be, I can't imagine contorting endwise into figuring out multiple endings (')' and '}') in a single line. It would probably require an entirely new algorithm, one that I can't even conceive of (yet, anyways).

tpope avatar Feb 16 '11 00:02 tpope

Something like autoclose (my fork) (or snippets, e.g. via snipMate) might work better in this case, or good enough as a workaround for now.

blueyed avatar Apr 05 '11 22:04 blueyed

What's lacking in autoclose is that it won't break open the

$('bleh').click(function() {|})

into

$('bleh').click(function() {
  |
})

I've been working on a way to do this, but then I realized that imaping <CR> breaks endwise. Is there a good way for two things to watch for <CR>?

Peeja avatar May 17 '11 02:05 Peeja

There's not a good way. If endwise finds an existing <CR> map, it'll include it, so in theory it's possible to chain.

tpope avatar Jun 01 '11 02:06 tpope

Is this plugin meant to close C-style blocks? I had the impression it was for VimScript-style blocks. C-style blocks should probably be closed by other plugins. I have found several in addition to Autoclose, which was mentioned above: ClosePairs, lhBrackets, delimitMate, and auto-pairs. I have not tried any of these yet, so this is not an endorsement; just an attempt to give some leads to future viewers of this thread. There is further info at this wikia page.

Kazark avatar Nov 20 '13 18:11 Kazark

This doesn't work as expected with delimitMate. It uses a setting delimitMate_expand_cr to determine if: {|<CR>} should turn into:

{
    |
}

Obviously this setting is set in a user's vimrc. Since it's set conditionally here only if there isn't an existing mapping for <CR> what ends up happening is it's sourced and it ignores that mapping the first time through. Then endwise is sourced, adding a mapping like there is no other <CR> mapping. And then the second time delimitMate calls the maps, there is a <CR> mapping so it is not overwritten. This obviously isn't the fault of endwise, but more of an FYI. I'm not sure how to circumvent this besides attempting to not load endwise based on some filetypes where you'd prefer the delimitMate functionality.

On another note this conditional in endwise can also not be used in a user's vimrc (assuming the plugins are loaded first) since the functions would already be mapped before the variable was defined.

keith avatar Mar 26 '14 22:03 keith

I almost got around by creating the mapping myself with:

execute "imap <CR> <Plug>delimitMateCR <Plug>DiscretionaryEnd"

But that messes up endwise to where, in Ruby this happens:

if foo<CR>

Turns into:

if foo
    |
    end

keith avatar Mar 26 '14 22:03 keith

The naive solution works without delimitMate's help:

execute "inoremap {<CR> {<CR>}<ESC>O"

keith avatar Mar 26 '14 22:03 keith