Vim: file modified when using `jj` as <Esc>

Created on 12 Feb 2018  路  6Comments  路  Source: VSCodeVim/Vim

BUG REPORT:

What happened:
when using jj as (or other two keys combination) on not modified file it becomes modified

What did you expect to happen: keep file unmodified

How to reproduce it (as minimally and precisely as possible):
Remap to jj
open file
go to insert mode, press jj

file not changed but vscode says it's modified

statuduplicate upstreavscode

All 6 comments

:+1:

Not entirely sure how we could solve this. The extension will temporarily insert the jj to the text document and then when it figures out it's a remapping, delete the jj and instead use an <Esc>. However, since we did actually modify the file, VSCode marks it as dirty.

There's no way as an extension to tell VSCode to state this file isn't actually dirty, and I doubt that they would ever expose such a thing.

Same root cause as https://github.com/VSCodeVim/Vim/issues/565. Let's use that issue instead to track.

EDIT

nope, my solution below isn't working correctly.


obsolete solution

my current way to solve this is to set `jk` to:

  "vim.insertModeKeyBindings": [
    {
      "before": ["j", "k"],
      "after": ["<Esc>", "u", "u"]
    }
  ],
while `u` stands for `undo`:
"vim.normalModeKeyBindingsNonRecursive": [
    {
      "before": ["u"],
      "after": [],
      "commands": [
        {
          "command": "undo",
          "args": []
        }
      ]
    }
]
hope this helps

this also deletes everything that you typed before pressing jk

yes, just realized it after I used it for a while. sorry

this also deletes everything that you typed before pressing jk

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cckowin picture cckowin  路  3Comments

liamdawson picture liamdawson  路  3Comments

elithrar picture elithrar  路  3Comments

waltiam picture waltiam  路  3Comments

lucastheisen picture lucastheisen  路  3Comments