Skip to content

Visual block operation shall end by turning into normal mode #803

Closed

Description

@vlcinsky

The #792 fixed issue with block operations. One can e.g. prefix set of lines with some text.

The operation works as follows:

  • Ctrl-v: to activate V-BLOCK mode: to start selecting block of text
  • mark the rectangular block
  • do the operation (e.g. I- to insert text at the first line column and add -
  • press Esc to complete the edit in block mode
  • the operation shall be performed on all the lines in the block
  • it shall switch to normal mode

At this moment, desktop version 2.51.1, the final step does not happen. Instead, insert mode is active.

Activity

  1. self-assigned this
    on Sep 17, 2026
  2. adibhanna commented on Sep 17, 2026

    @adibhanna
    Contributor

    Thanks for the precise steps, and for checking #792 so soon after it shipped. Your sequence reproduced it first try.

    Reproduced on 2.51.1 in the built desktop app: Ctrl-v, j, j, I, - , Esc put the text on every row and left the editor in insert mode, with typing still going into the note. Ctrl-[ ended the same edit in normal mode correctly, which pointed at the Escape key itself rather than at the block edit.

    Cause. The editor's keymaps get every key before the Vim layer does, and two of them were spending Escape:

    • CodeMirror's default keymap uses Escape to collapse multiple cursors. Visual rectangular block edits not working as in vim #792 made block edits real multi-cursors, so from that release on Escape collapsed the cursors, reported the key as handled, and Vim never heard it.
    • The autocomplete keymap takes Escape while a completion is pending, and every typed character counts as pending for about 100ms even when no popup ever appears. So an Escape pressed right after the last character was lost too. That one affected ordinary single-cursor inserts as well, and would have kept block edits stuck for fast typists even with the first part fixed.

    What changes for you

    • A block I, A or c followed by Esc ends in normal mode with a single cursor. u then undoes the whole block edit in one step.
    • Leaving visual block (Ctrl-v ... Esc) takes one press. It needed two since Visual rectangular block edits not working as in vim #792, for the same reason.
    • After v or V, Esc leaves the cursor where Vim puts it (on the last selected character) instead of one position off.
    • Esc pressed immediately after typing is never swallowed. Handy with Escape on Caps Lock.
    • Unchanged: with a completion popup actually on screen, the first Esc still closes the popup and keeps you in insert mode.

    Verified in the built app over real key events across 15 scenarios, all matching Vim. The earlier #792 tests claimed "returns to normal mode" and passed, because the test harness mounted Vim ahead of the keymaps, the reverse of the real editor. That is fixed too, and the new tests fail without this change.

    Status. Committed as 81798b43 on the v2.52.0 branch. It ships in 2.52.0, which is not released yet.

    Closing since the fix is in. If 2.52.0 still leaves you in insert mode after a block edit, comment here and I'll reopen.

  3. added
    bug
    vim
    editor
    on Sep 17, 2026
  4. added theissue type on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugeditorvim

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions