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

$ command takes newline in visual mode #3970

Closed
pattersongp opened this issue Aug 8, 2019 · 16 comments
Closed

$ command takes newline in visual mode #3970

pattersongp opened this issue Aug 8, 2019 · 16 comments

Comments

@pattersongp
Copy link

Describe the bug
When in visual mode, using the $ command should take you to the last character of a line, not including the new line, if present.

To Reproduce
Steps to reproduce the behavior:

  1. Go into visual mode.
  2. Use $ to go to the end of line, but end with the cursor on the next line.

Expected behavior
The expected behavior is stopping at the last character, that is not a new line.

Environment

  • Extension (VsCodeVim) version: v1.9.0
  • VSCode version: 1.36.1
  • OS: macos x 10.14.5
@pattersongp
Copy link
Author

A note: this feature works in normal mode. This issue is only with respect to visual mode.

@renodubois
Copy link

Just wanted to second that I've seen this issue as well. Same circumstances, same behavior.

Environment

  • Extension (VSCodeVim) version: v1.9.0
  • VSCode Version: 1.37.0
  • OS: macOS 10.14.5

@J-Fields J-Fields changed the title $ command takes newline $ command takes newline in visual mode Aug 19, 2019
@stevenguh
Copy link
Contributor

@J-Fields
Copy link
Member

J-Fields commented Sep 2, 2019

@stevenguh You're right, thanks for pointing that out. I'll fix that this afternoon.

@J-Fields
Copy link
Member

J-Fields commented Sep 2, 2019

@pattersongp I swear I replicated this in vanilla vim the other day, but now when I try v$ in vim, it does include the EOL. We have tests for this case. Can you verify that this isn't actually how vim behaves?

J-Fields added a commit that referenced this issue Sep 2, 2019
This is, apparently, not how vim works (though I thought I tested vim's behavior the other day...)
Refs #3970
@stevenguh
Copy link
Contributor

v$ will include the EOL character for me in vanilla Vim

@pattersongp
Copy link
Author

This is vanilla vim:
https://asciinema.org/a/xrzqlrtqiAZwZeIUvfnPI47rp

@stevenguh
Copy link
Contributor

stevenguh commented Sep 4, 2019

That video is already showing v$ including the new line character. Try using vg_ to see the difference.

You can see the difference if you enter two lines of text.
ggv$y and paste it somewhere
This will include a EOL
vs
ggvg_y and paste it somewhere
This will not include a EOL

@Ashymad
Copy link

Ashymad commented Sep 4, 2019

Indeed, v$ will select the EOL as well (checked in neovim). The difference is only visual, in vim the cursor doesn't appear in the next line after v$, while in VSCodeVim it does.

@pattersongp
Copy link
Author

I agree that the EOL is taken into the clipboard, but the cursor should not appear on the following line. Sorry-- the issue should be cursor appears on next line after v$

@stevenguh
Copy link
Contributor

I think that's the limitation of VS Code, but I don't know enough to say for sure.

@J-Fields
Copy link
Member

J-Fields commented Sep 4, 2019

Yes, I believe this is not possible in VSCode. Another rendering limitation is that the block cursor is wider when on top of a tab character.

@wandaud
Copy link

wandaud commented Jun 10, 2022

hey, so this bug still can't be fixed?

@CanonRouge24
Copy link

At least, as mentioned, there exists an alternate motion g_ that does work as we want.

You can rebind $ to g_ (I personally swapped the two, as follows):

(in settings.json)

"vim.visualModeKeyBindingsNonRecursive": [
    {
        "before": ["$"],
        "after": ["g", "_"]
    },
    {
        "before": ["g", "_"],
        "after": ["$"]
    }
]

@tekboart
Copy link

At least, as mentioned, there exists an alternate motion g_ that does work as we want.

You can rebind $ to g_ (I personally swapped the two, as follows):

(in settings.json)

"vim.visualModeKeyBindingsNonRecursive": [
    {
        "before": ["$"],
        "after": ["g", "_"]
    },
    {
        "before": ["g", "_"],
        "after": ["$"]
    }
]

Thank you CanonRouge24, your solution solved the aforementioned problem for me. I've been entangled with this problem for over 2 years now, but now thanks to you it's resolved for good.

@darianmorat
Copy link

darianmorat commented Dec 27, 2023

At least, as mentioned, there exists an alternate motion g_ that does work as we want.

You can rebind $ to g_ (I personally swapped the two, as follows):

(in settings.json)

"vim.visualModeKeyBindingsNonRecursive": [
    {
        "before": ["$"],
        "after": ["g", "_"]
    },
    {
        "before": ["g", "_"],
        "after": ["$"]
    }
]

But this is modifying a DEFAULT VIM behavior. I wouldn't do that, the only problem is visual, cause it shows the cursor in the second line. But actually that is going to give a better understanding to people who don't know that much about VIM, about how it actually works

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

9 participants