VSCodeVim / VSCodeVim/Vim

`vmap J :m '>+1<CR>gv=gv` and `vmap K :m '<-2<CR>gv=gv` do not work as expected

Open
#9,262 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug
vmap J :m '>+1<CR>gv=gv and vmap K :m '<-2<CR>gv=gv do not work as expected.
These mappings work in vim but not in VSCodeVim. Normally, they allow you to highlight a few lines and then move them with J or K.

To Reproduce
Steps to reproduce the behavior:

  1. Add the two remaps above to your .vimrc.
  2. In VSCodeVim, use them by highlighting a line with V. Then try moving the line down with the J mapping.
  3. Observe these mappings do not work.

Expected behavior
Normally, these maps allow you to highlight a few lines and then move them with J or K.

Log

2024-09-15 14:50:01.540 [debug] Handling key: V
2024-09-15 14:50:01.541 [debug] Status bar: -- VISUAL LINE --
2024-09-15 14:50:03.263 [debug] Handling key: J
2024-09-15 14:50:03.263 [debug] Remapping J to :,m, ,',>,+,1,
,g,v,=,g,v
2024-09-15 14:50:03.263 [debug] Handling key: :
2024-09-15 14:50:03.287 [debug] Status bar: :'<,'>|
2024-09-15 14:50:03.287 [debug] Handling key: m
2024-09-15 14:50:03.290 [debug] Status bar: :'<,'>m|
2024-09-15 14:50:03.290 [debug] Handling key:
2024-09-15 14:50:03.294 [debug] Status bar: :'<,'>m |
2024-09-15 14:50:03.294 [debug] Handling key: '
2024-09-15 14:50:03.297 [debug] Status bar: :'<,'>m '|
2024-09-15 14:50:03.298 [debug] Handling key: >
2024-09-15 14:50:03.300 [debug] Status bar: :'<,'>m '>|
2024-09-15 14:50:03.301 [debug] Handling key: +
2024-09-15 14:50:03.304 [debug] Status bar: :'<,'>m '>+|
2024-09-15 14:50:03.304 [debug] Handling key: 1
2024-09-15 14:50:03.307 [debug] Status bar: :'<,'>m '>+1|
2024-09-15 14:50:03.307 [debug] Handling key:
2024-09-15 14:50:03.308 [info] Executing :'<,'>m '>+1
2024-09-15 14:50:03.308 [debug] Adding Transformation {"type":"deleteRange","range":[{"line":3,"character":0},{"line":4,"character":0}],"manuallySetCursorPositions":true}
2024-09-15 14:50:03.308 [debug] Adding Transformation {"type":"insertText","position":{"line":4,"character":6},"text":"\n\t"context"","diff":{"type":0,"line":4,"character":1}}
2024-09-15 14:50:03.319 [debug] 2 change(s) to c:\Users\KhanY_z23jg7i\repos\price-fetcher\metrics.go because undefined
2024-09-15 14:50:03.321 [debug] Set nextStepStartPosition to [3, 0]
2024-09-15 14:50:03.321 [debug] Status bar: -- NORMAL --
2024-09-15 14:50:03.321 [debug] Handling key: g
2024-09-15 14:50:03.323 [debug] Handling key: v
2024-09-15 14:50:03.324 [debug] Status bar: -- VISUAL LINE --
2024-09-15 14:50:03.324 [debug] Handling key: =
2024-09-15 14:50:03.366 [debug] Status bar: -- NORMAL --
2024-09-15 14:50:03.366 [debug] Handling key: g
2024-09-15 14:50:03.367 [debug] Handling key: v
2024-09-15 14:50:03.368 [debug] Status bar: -- VISUAL LINE --
2024-09-15 14:50:03.368 [debug] Finished history step with 2 change(s)
2024-09-15 14:50:03.802 [debug] Handling key: J
2024-09-15 14:50:03.803 [debug] Remapping J to :,m, ,',>,+,1,
,g,v,=,g,v
2024-09-15 14:50:03.803 [debug] Handling key: :
2024-09-15 14:50:03.826 [debug] Status bar: :'<,'>|
2024-09-15 14:50:03.826 [debug] Handling key: m
2024-09-15 14:50:03.830 [debug] Status bar: :'<,'>m|
2024-09-15 14:50:03.830 [debug] Handling key:
2024-09-15 14:50:03.834 [debug] Status bar: :'<,'>m |
2024-09-15 14:50:03.834 [debug] Handling key: '
2024-09-15 14:50:03.837 [debug] Status bar: :'<,'>m '|
2024-09-15 14:50:03.838 [debug] Handling key: >
2024-09-15 14:50:03.841 [debug] Status bar: :'<,'>m '>|
2024-09-15 14:50:03.841 [debug] Handling key: +
2024-09-15 14:50:03.844 [debug] Status bar: :'<,'>m '>+|
2024-09-15 14:50:03.845 [debug] Handling key: 1
2024-09-15 14:50:03.848 [debug] Status bar: :'<,'>m '>+1|
2024-09-15 14:50:03.849 [debug] Handling key:
2024-09-15 14:50:03.849 [info] Executing :'<,'>m '>+1
2024-09-15 14:50:03.849 [debug] Adding Transformation {"type":"deleteRange","range":[{"line":3,"character":0},{"line":4,"character":0}],"manuallySetCursorPositions":true}
2024-09-15 14:50:03.849 [debug] Adding Transformation {"type":"insertText","position":{"line":4,"character":10},"text":"\n\t"fmt"","diff":{"type":0,"line":4,"character":1}}
2024-09-15 14:50:03.854 [debug] 2 change(s) to c:\Users\KhanY_z23jg7i\repos\price-fetcher\metrics.go because undefined
2024-09-15 14:50:03.854 [debug] Set nextStepStartPosition to [3, 0]
2024-09-15 14:50:03.855 [debug] Status bar: -- NORMAL --
2024-09-15 14:50:03.855 [debug] Handling key: g
2024-09-15 14:50:03.857 [debug] Handling key: v
2024-09-15 14:50:03.857 [debug] Status bar: -- VISUAL LINE --
2024-09-15 14:50:03.857 [debug] Handling key: =
2024-09-15 14:50:03.874 [debug] Status bar: -- NORMAL --
2024-09-15 14:50:03.874 [debug] Handling key: g
2024-09-15 14:50:03.876 [debug] Handling key: v
2024-09-15 14:50:03.876 [debug] Status bar: -- VISUAL LINE --
2024-09-15 14:50:03.876 [debug] Finished history step with 2 change(s)
2024-09-15 14:50:09.734 [debug] Handling key:
2024-09-15 14:50:09.735 [debug] Status bar: -- NORMAL --
2024-09-15 14:50:11.993 [info] Active editor: output:vscodevim.vim.Vim

Environment (please complete the following information):

  • Extension (VsCodeVim) version: v1.28.1
  • VSCode version: Version: 1.93.1 (user setup)
  • OS: Windows 11

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

No source file or test is named. Start by reproducing the vmap J and vmap K mappings in VSCodeVim using the documented Visual Line workflow, then trace the logged command handling. Done means both mappings move the selected lines as they do in Vim and retain the expected selection behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.