vim-endwise
vim-endwise copied to clipboard
Request for javascript? :D
$('bleh').click(function() { |(cursor here) , possibility to add missing ; ? })
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).
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.
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 imap
ing <CR>
breaks endwise. Is there a good way for two things to watch for <CR>
?
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.
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.
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.
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
The naive solution works without delimitMate's help:
execute "inoremap {<CR> {<CR>}<ESC>O"