VSCodeVim / VSCodeVim/Vim

Remapping the GOTO Line function from `G` to `<Enter>` in normal mode

Open
#3,417 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/remap kind/bug
Dominant language
TypeScript
Stars
15.2k
Forks
1.5k
Avg merge
3d 18h
Merged PRs (30d)
6

Description

Current Attempt

When remapping the GOTO LINE function, the extension assumes I mean 'G' as in jump to end of file. Rather than 'Shift-G' which would be GOTO LINE.

I'm trying to remap the ENTER key inside normal mode to .

Basically trying to reproduce this: http://vim.wikia.com/wiki/Jump_to_a_line_number

This is what I have so far inside my settings.json:

"vim.normalModeKeyBindings": [
    {
        "before": ["<CR>"],
        "after": ["G"]
    },

So, if I give it a number in normal mode and do 12 + Enter then it should goto line 12. I just get straight to EOF as if I just typed Shift+g on it's own, so it ignores my number.

Possible Idea

I wouldn't mind doing this in the keybindings.json with something like this:

{
    "key": "enter",
    "command": "vim.gotoline?",
    "when": "editorTextFocus && vim.mode != 'Insert'"
}

However I don't know if vim's GOTOLINE function is exposed and if it is I don't know what to write for "command"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the vim.normalModeKeyBindings example in settings.json and the proposed keybindings.json entry; inspect how a numeric prefix is carried into and whether the suggested command exists. Done means that entering a number followed by Enter in normal mode moves to that line instead of jumping to EOF.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.