1

I want Backspace key to remove only one space all the time, but after installing delimitMate, it removes extra space. Let's say I want to type the code below.

let hello = "some text";

While I'm typing this, I accidentally type extra space after hello, so there are two spaces between hello and my cursor as follows.

let hello  |

And, at this point, I decide to remove one space with Backspace, but it removes two spaces instead, so the cursor ends up next to o as in hello as follows.

let hello|

Now, I have to type space again to make sure there is one space between hello and =. This is redundant and I don't like this. Does anyone know how to make Backspace remove only one space all the time with delimitMate installed?

Edit:

Thanks to the comment from B Layer, I found the mapping that was causing this. After commenting out the mapping code, I was able to remove only one space with Backspace key, but now when I delete a matching pair, it only deletes the opening one, and the closing one stays intact.

Before

{|}

Input

<BS>

After

}
6
  • "Backspace command"? Do you just mean the backspace key? If so does :imap <bs> show anything? If so, try :verbose imap <bs> to see where the mapping is being created.
    – B Layer
    Oct 9, 2021 at 13:53
  • Yes, backspace key. I will edit it. :verbose imap <bs> showed that silent! imap <unique> <buffer> <BS> <Plug>delimitMateBS was the mapping, but I don't know how to fix it.
    – tet
    Oct 9, 2021 at 14:04
  • After taking a quick look at the docs to see the intended purpose of the backspace mapping it sounds like that behavior might be a bug. I think it should only do something if you're between paired delimiters. You might want to open an issue at the plugin's github site.
    – B Layer
    Oct 9, 2021 at 19:46
  • (Or if it's a "feature" they might be able to tell you how to selectively disable it...whether through available configuration or by hacking the code.)
    – B Layer
    Oct 9, 2021 at 19:58
  • 1
    I opened an issue at github.com/Raimondi/delimitMate/issues/297. Thank you for your suggestions.
    – tet
    Oct 10, 2021 at 1:10

1 Answer 1

0

The creator of delimitMate gave me a solution that worked for me. I'm a Rust programmer and this solution is specific for Rust files, so I don't know how this works for other files.

Add au FileType rust set sts=0 to your neovim config file.

Now, when you press the backspace key, it only removes one space. Take a look at the issue I opened at github for details, which led me to this solution.

3
  • You shouldnt have to modify the plugin. Just put the setlocal in ~/.vim/after/ftplugin/rust.vim.
    – D. Ben Knoble
    Oct 13, 2021 at 12:09
  • Adding setlocal in ~/.vim/after/ftplugin/rust.vim had no effect for me. Instead, adding au FileType rust set sts=0 to my neovim config file worked.
    – tet
    Oct 13, 2021 at 12:36
  • Well the path is different on neovim but the idea should work
    – D. Ben Knoble
    Oct 13, 2021 at 13:02

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.