remapping cursor movement keys in insert mode
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.2k
- Forks
- 1.5k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 6
Description
Generally I'm not a friend of cursor movement in insert mode. In the very most cases after I moved the cursor I want to type a command (cw, ct, cf, dt, df, yw, Y, p, P or in many many cases just .), not any text, this is my experience for 30 years now. But many vi emulations remain in insert mode after pressing a cursor movement key. I find this more obstructive than helpful.
So I normally remap the cursor keys in insert mode as follows:
<left> --> <esc>
<right> --> <esc> l
<up> --> <esc> l k
<down> --> <esc> l j
(also some more keys like Home, End, PgUp and PgDn)
In VSCodeVim/Vim this should look like this:
"vim.insertModeKeyBindingsNonRecursive": [
{"before": ["<left>"], "after": ["<esc>"]},
{"before": ["<right>"], "after": ["<esc>", "l"]},
{"before": ["<up>"], "after": ["<esc>", "l", "k"]},
{"before": ["<down>"], "after": ["<esc>", "l", "j"]}
],
But it doesn't work very well. It's just not reliable, sometimes the insert mode is terminated, in the most cases it is not. Sometimes the cursor moves to the expected position, sometimes it moves somewhere else. Why? I also see a visible selection being displayed for a short moment. Why???
What I expect is: <esc> should always and under all circumstances terminate the insert mode and switch to the normal mode, where keys like h or j or k or l should do a reliable cursor movement.
I also detected that cursor movement in normal mode is also not really good, especially up and down. Try this in your settings.json file: go onto the first letter of any line, this is the character right of a " and then move up and down using the arrow keys or j and k. The cursor should always stay in the same column but it doesn't. On some lines the cursor jumps three characters to the right. Why? These lines seem to be always the same lines, so they must have a hidden criterion which leads to the jump, but what is it?
My environment is
- Visual Studio Code 1.36.0
- VIM 1.8.1
- Windows 10 Pro 1809
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the insert-mode and normal-mode cursor movement reports using the settings.json keybindings described in the issue. Compare arrow-key and h/j/k/l behavior in the stated VS Code and Vim extension environment; done means insert-mode mappings consistently enter normal mode and vertical movement preserves the intended column.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vscode
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100