I have to following lines in my .vimrc file (being .vimrc is irrelevant, other files the same),

noremap D "_d  

"Make Y behave like other capitals (C, D)
nnoremap Y y$

When I started to delete "_d from the end using <BS>, immediately after the " is removed, automatically, the text rewraps to

vnoremap D Make Y behave like other capitals (C, D)
nnoremap Y y$

My possible related settings are comments=sO:" -,mO:" ,eO:"",:" and formatoptions=tcq (which seems irrelevant after several test). What is causing this problem? And how can I disable it such that the normal editing result

noremap D 

"Make Y behave like other capitals (C, D)
nnoremap Y y$

is recovered if I do the same delete.

  • It looks like you're using a plug-in such as auto-pairs, which will automatically add the closing ), ], } or " for you. It will also remove the pair when you delete the first one with backspace and it finds "nothing" in between the pair. Which is somewhat the case here, if you consider that the two "s make a pair... So that might explain this behavior you're seeing. – filbranden May 19 '20 at 4:50
  • 3
    Personally, I find that a plug-in such as auto-pairs in the end is more trouble than benefit. In many/most cases, you end up typing the closing brackets anyways to go past them. Yeah you can save a couple keystrokes here and there, but the savings are never really that huge. (Well, perhaps if you're writing LISP.) I'd recommend disabling them for the most part. – filbranden May 19 '20 at 4:52
  • 1
    Yes, auto-pairs is to blame. Very glad to know the reason finally, thanks a lot! – Kevin Powell May 19 '20 at 6:19
  • 1
    @filbranden fwiw I write a fair bit of lisps in vim and dont miss autopairs (%, syntax highlights, and a good linter give me most of the warning I need, and structural editing provides the rest) – D. Ben Knoble May 19 '20 at 13:12
  • 1
    @KevinPowell I’ve removed the second question from your post (we try to stick to one per post around here). You can find it in the edit history if you want to repost it as a second question; you’re more likely to get a proper answer that way (to my eyes it seems unrelated to the autopairs issue) – D. Ben Knoble May 19 '20 at 13:17

If you are using an auto-pairs-style plugin, it is most likely trying to delete the closing "; not finding one, it erroneously deletes further.

As mentioned in the comments, these plugins generally cause more headache than they’re worth (YMMV). Snippets provide a more flexible alternative (though the author has very little experience with them).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.