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

Go to next line (move the caret one line down independent of word wrap) #116418

Closed
mstenemo opened this issue Feb 11, 2021 · 11 comments
Closed

Go to next line (move the caret one line down independent of word wrap) #116418

mstenemo opened this issue Feb 11, 2021 · 11 comments
Assignees
Labels
editor-commands Editor text manipulation commands feature-request Request for new features or functionality

Comments

@mstenemo
Copy link

mstenemo commented Feb 11, 2021

I am requesting a command to move the caret to the beginning of next/previous line, and if shift is also held down (eg using ctrl+shift+up/down) it should select text from the caret to beginning/end of current line. The difference between using shift+home is that hitting ctrl+shift+up multiple times would add another line each time, while +home does not expanding selection.

Similar commands are implemented almost universally with crtl+up/down both in editors (eg in Sublime and Emacs to move between code blocks), and in other common programs (eg GitHub, Word, Gmail) to move/select text between paragraphs or on the same line when the line is affected by word wrap).

This is slightly different from the recently added prevBlankLine and nextBlankLine cursorMove command (Insiders' Build for v1.54) for moving between code blocks like in Sublime and Emacs.

@alexdima
Copy link
Member

This can be done by using the cursorMove command. This command is used internally by all other cursor navigation commands. e.g.:

{
    "key": "down",
    "command": "cursorMove",
    "args": { "by": "line", "to": "down" },
    "when": "editorTextFocus"
}

@alexdima alexdima added the info-needed Issue requires more information from poster label Feb 25, 2021
@mstenemo
Copy link
Author

This can be done by using the cursorMove command. This command is used internally by all other cursor navigation commands. e.g.:

{
    "key": "down",
    "command": "cursorMove",
    "args": { "by": "line", "to": "down" },
    "when": "editorTextFocus"
}

Possible to make this accessible in the "keyboard shortcuts" settings?

@alexdima
Copy link
Member

AFAIK The rich keyboard shortcuts editor cannot currently edit the args or when section of a keybinding. This is tracked in #84072

@mstenemo
Copy link
Author

mstenemo commented Mar 6, 2021

AFAIK The rich keyboard shortcuts editor cannot currently edit the args or when section of a keybinding. This is tracked in #84072

This means that this is not a solution to my request. Any more information that is needed @alexdima?

@alexdima
Copy link
Member

alexdima commented Mar 9, 2021

@mstenemo I think you brought up two issues:

  1. how to move cursor down by logical lines (not by wrapped lines). I have provided you with the keybinding rule you can use in your keybindings.json. By using intellisense in keybindings.json you can discover how to create also a keybinding rule for moving the cursor up, for selecting up, for selecting down, etc. I did not write each and every one, I think you can discover them by using ctrl+space.
  2. the fact that you cannot edit the args and when fields in the Keybindings Editor UI. That is being tracked in Allow viewing and editing commands with 'args' in the keybindings editor #84072

Is there something missing?

@mstenemo
Copy link
Author

mstenemo commented Mar 9, 2021

Thank you for the clarification Alexdima, the fact that It was closed as "more information needed" indicated that you still waited for information.

Your solution does not give the desired result: I want eg ctrl+up to move to the beginning of the previous paragraph, but this would require two actions (which is not possible by default? So using an extension would be required?

If this is the case, it should be possible for me to implement, but not ideal for new users. If so, I guess my remaining issue is if this command is important enough to motivate having its own setting in the keyboard shortcuts.

I assume there is a good reason why your suggested solution is preferred (although not possible as mentioned in your second point) over adding a new command that is discoverable using the keyboard shortcut directly?

For very uncommon command I could see a point in not having it available in the keyboard shortcuts by default, although this very common command is implemented almost universally with crtl+up/down (eg in Emacs to move between paragraphs as well as word wrap), and there are many users who would prefer this by default but not have to go through the processes of adding another completely different solution just to implement it.

@alexdima
Copy link
Member

alexdima commented Mar 9, 2021

I don't think we have a built-in command which would do exactly what you describe: going to the beginning of the previous paragraph / the beginning of the next paragraph. We can leave this issue open to track this feature request.

I haven't seen this command in other code editors. For example, lots of code editors use ctrl+up/down for scrolling the viewport without moving the cursor. We do have another variant that might be helpful if you leave a one line gap between paragraphs: e.g. here is what I personally bind to ctrl+up/down:

{ "key": "ctrl+up",	"command": "cursorMove", "when": "editorTextFocus", "args": { "to": "prevBlankLine", "by": "wrappedLine" } },
{ "key": "ctrl+down",	"command": "cursorMove", "when": "editorTextFocus", "args": { "to": "nextBlankLine", "by": "wrappedLine" } },

So let's leave this issue open for tracking the feature request for a command that moves to the beginning of the previous/next line.

@alexdima alexdima reopened this Mar 9, 2021
@alexdima alexdima added editor-commands Editor text manipulation commands feature-request Request for new features or functionality and removed info-needed Issue requires more information from poster labels Mar 9, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jun 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-commands Editor text manipulation commands feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants
@jrieken @mstenemo @alexdima and others