question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to move cursor using vim in vscode without forgetting previous column?

See original GitHub issue

More like an question than a feature request. If it is fundamental, I apology but I just failed find the way.

Here is current status: (where ---^--- denotes the cursor)

#include <iostream>

int main() {
    std::cout << "Hello world\n";
//------------------^-------------------

    std::cout << "hello world\n";
}

after press jj in normal mode:

#include <iostream>

int main() {
    std::cout << "Hello world\n";

    std::cout << "hello world\n";
^--------------------------------
}

What I want:

#include <iostream>

int main() {
    std::cout << "Hello world\n";
//------------------^-------------------

    std::cout << "hello world\n";
}

after press jj:

#include <iostream>

int main() {
    std::cout << "Hello world\n";

    std::cout << "hello world\n";
//------------------^-------------------
}

How can I achieve this?

Here is my vim settings

    // vim settings
    "vim.easymotion": true,
    "vim.useSystemClipboard": true,
    "vim.normalModeKeyBindings": [
            {
                "before": ["u"], 
                "after": [],
                "commands": [
                    {
                        "command": "undo", 
                        "args": [], 
                    }
                ] 
            },
            {
                "before": ["<C-r>"], 
                "after": [],
                "commands": [
                    {
                        "command": "redo", 
                        "args": []
                    }
                ] 
            },  
            {
                "before": ["j"], 
                "after": ["g","j"], 
            },
            {
                "before": ["k"], 
                "after": ["g","k"], 
            },
    ],
    "vim.statusBarColors.commandlineinprogress": "",
    "vim.leader": "<space>",
    // "vim.useCtrlKeys": true,
    "vim.handleKeys": {

        "<C-a>": false,
        "<C-f>": true,
        "<C-r>": true,
        "<C-y>": false,
        "<C-d>": true, 
    },
    "vim.overrideCopy": true,
    "vim.smartRelativeLine": true,
    "editor.lineNumbers":"relative", 

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
chewcwcommented, May 14, 2022

If you remove this binding then it should work like what you want.

{
    "before": ["j"], 
    "after": ["g","j"], 
},
{
    "before": ["k"], 
    "after": ["g","k"], 
}
0reactions
Adnioscommented, Jun 9, 2022

If you remove this binding then it should work like what you want.

This is correct; it’s a known bug

I think C-d and C-u has the same issue (forgetting previous column). It’s so strange for vim user. 😭

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to move cursor using vim in vscode without forgetting ...
Recently I install vscodevim extension on vscode. Everthing works fine except moving the cursor across line bothers me.
Read more >
Visual Studio Code Tips and Tricks
You can quickly open a file or image or create a new file by moving the cursor to the file link and using...
Read more >
Introduce a move command for moving cursor in the editor
Introduce a move command for moving cursor at a logical view position in the ... the cursor (no selection) editor.selections = [new vscode....
Read more >
Multiple Cursors - Barbarian Meets Coding
Move the cursor on top of a word in your code. Type <CMD-D> ( CTRL-D on Windows/Linux) or gb to add another cursor....
Read more >
What is the equivalent of VS Code's "Ctrl+Shift+L" in Vim?
In VS Code, when you select a text and hit Ctrl+Shift+L, all occurrences of the selected text are also selected. For example, in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found