1

TL;DR: da( doesn't delete the following space like daw does. Can I make this do what I want easily?

I have some sample lines (cursor is shown as |):

1. Sample line (extraneous| statement) in notes.
2. Sample line extra|neous in notes.

On line 2, daw will leave me with a complete, well-written sentence: Sample line in notes.

On line 1, da( will leave extra spaces: Sample line in notes., which is undesirable.

I know I could make a completely custom bind that does da(dl to avoid this issue, but I would like to use da( rather than some new key combination, and I don't know how I could remap that. I read motion.txt in :help and it looks like this isn't possible, but I figured I could be missing something.

2

If you wanted to remap a(

onoremap a( :<C-u>normal! va(l<CR>

This should make all uses of it include the space.

3
  • da( with your remap on My (parenthetical st|atement) sentence yields My )| sentence. Nov 16 '20 at 14:24
  • @jeremysprofile good catch; I forgot that the rhs is not executed in normal mode! Try the edit
    – D. Ben Knoble
    Nov 16 '20 at 15:07
  • 2
    Perfect! I prefer the individual remap to a full plugin, so this is ideal for me. Note to others that you will have to remap each wrap (a[, a{, a", etc) if you need this behavior for other wrappings. Nov 16 '20 at 15:23
2

Plug-in wellle/targets.vim includes an operator mapping for this specific situation. The mapping is A( or Ab, which is analogous to a( but includes the whitespace following the pair.

See the plug-in's documentation for the "Around Pair" operator.

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.