Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

va" and ya" includes spaces and tabs before quote #6800

Closed
boenshao opened this issue Jun 27, 2021 · 3 comments
Closed

va" and ya" includes spaces and tabs before quote #6800

boenshao opened this issue Jun 27, 2021 · 3 comments

Comments

@boenshao
Copy link

Describe the bug
When quoted (" or ') content is prepended with spaces or tabs, visual select (va", va') and yank (ya", ya') would incorrectly includes the spaces or tabs.

To Reproduce
Steps to reproduce the behavior:

  1. echo " \"quoted after spaces\"\n\t'quoted after tab'" > test.txt
  2. code test.txt
  3. navigate inside the quotes
  4. va", va', ya" or ya'

Expected behavior
Visual select (or yank) the content (include the quotes), but exclude spaces or tabs before the quote.

Screenshots
image

  • Extension (VsCodeVim) version: 1.21.3
  • VSCode version: 1.57.1
  • OS: macOS 11.4 and Ubuntu 20.10
@J-Fields
Copy link
Member

Actually, this is expected behavior. From :help a":

Any trailing white space is included, unless there is none, then leading white space is included.

However, in Vim you can achieve the behavior you want by mapping a" to 2i" (and similar for the other quotes). We don't yet support this special case, but I've created #6806, which I'll try to get in the next release.

@jonboiser
Copy link

However, in Vim you can achieve the behavior you want by mapping a" to 2i"

This is what I did to get this working, if any one comes across this.

    "vim.visualModeKeyBindings": [
        {
            "before": ["a","\""],
            "after": ["2", "i", "\""]
        },
        {
            "before": ["a","'"],
            "after": ["2", "i", "'"]
        },
        {
            "before": ["a","`"],
            "after": ["2", "i", "`"]
        },
    ]

@laggardkernel
Copy link

That is how va" works

  "vim.visualModeKeyBindingsNonRecursive": [
    {
      "before": ["a","\""],
      "after": ["2", "i", "\""]
    },
    {
        "before": ["a","'"],
        "after": ["2", "i", "'"]
    },
    {
        "before": ["a","`"],
        "after": ["2", "i", "`"]
    },
  ].
  "vim.normalModeKeyBindings": [
    // https://github.com/tpope/vim-surround/issues/276. nmap but not nnoremap
    {
      "before": ["y", "s", "a","\""],
      "after": ["y", "s", "2", "i", "\""]
    },
    {
        "before": ["y", "s", "a","'"],
        "after": ["y", "s", "2", "i", "'"]
    },
    {
        "before": ["y", "s", "a","`"],
        "after": ["y", "s", "2", "i", "`"]
    },
  ],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants