Skip to content

Custom surroundings don't work with cs or ds #329

@hbarcelos

Description

@hbarcelos

Using any type of quotation is a pain with US-intl keyboards, because you are always expected to type an extra Space to get things done:

Hello | world

To get the whole line into quotes, I have to press yss"Space:

"Hello | world"

That's how the keyboard is supposed to work and I won't try to mess with it. To make things a bit easier though, I created the following custom surroundings and mappings:

let g:surround_{char2nr("d")} = "\"\r\""
onoremap ad a"
xnoremap ad a"
onoremap id i"
xnoremap id i"

let g:surround_{char2nr("s")} = "'\r'"
onoremap as a'
xnoremap as a'
onoremap is i'
xnoremap is i'

let g:surround_{char2nr("a")} = "`\r`"
onoremap aa a`
xnoremap aa a`
onoremap ia i`
xnoremap ia i`

So if I have:

Hello | world
  • yssd gives me "Hello World"
  • ysss gives me 'Hello World'
  • yssa gives me `Hello World`

So far so good. However the issue is that I cannot use cs neither ds with the custom surroundings:

"Hello | world"

dsd and csd have no effect.

But if I use them as the target for cs, they do work:

"Hello | world"

cs"s gives me 'Hello World'.

Edit:

I also tried to create normal mode mappings like:

nnoremap dsd ds"

But if fails.

However, if I use nmap instead, then it works:

nmap dsd ds"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions