vim cursor is not visible on empty lines in command mode · Issue #6312 · codemirror/codemirror5 · GitHub
Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

vim cursor is not visible on empty lines in command mode #6312

Closed

Description

@DrXyzzy

Position the cursor on any empty line and hit escape. The cursor vanishes. The line must be completely empty, i.e. no whitespace or visible characters.

Seen with Chrome Version 83.0.4103.97 (Official Build) (64-bit) and Firefox 77.0.1 (64-bit) on macOS 10.15.5.

You can reproduce this in the Vim bindings demo at https://codemirror.net/demo/vim.html , which is at version 5.54.0 as of this writing.

Activity

  1. ppasupat commented on Dec 31, 2020

    @ppasupat
    Contributor

    Possibly related: #6393

    I had the same issue and found the following:

    • CodeMirror as of v5.59.0 has an issue where some non-mobile browsers might be detected as iOS and thus mobile (in src/util/browser.js). This is recently fixed in the master branch (See Incorrect iOS detection with Chrome on multi-touch supported Windows device (e.g. Surface Go) #6532).
    • The default inputStyle option for mobile browsers is "contenteditable".
    • The vim keymap uses a different method for showing the normal mode cursor (fat cursor) in contenteditable: it uses doc.markText to mark the current character. An empty line does not have any character, so the mark does not show up.

    One workaround is to explicitly set the option inputStyle: "textarea" in the CodeMirror initializer. Another is to change the line in codemirror.js that says

    var ios = !edge && /AppleWebKit/.test(userAgent) && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2);
    

    to

    var ios = safari && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2);
    
  2. schmoelder commented on Oct 16, 2021

    @schmoelder

    Is there anything that can be done to help fix this issue? It's really limiting CodeMirror's functionality for me.

  3. Komediruzecki commented on Oct 26, 2021

    @Komediruzecki

    Possibly related: #6393

    I had the same issue and found the following:

    * CodeMirror as of v5.59.0 has an issue where some non-mobile browsers might be detected as iOS and thus mobile (in `src/util/browser.js`). This is recently fixed in the master branch (See [Incorrect iOS detection with Chrome on multi-touch supported Windows device (e.g. Surface Go) #6532](https://github.com/codemirror/CodeMirror/issues/6532)).
    
    * The default `inputStyle` option for mobile browsers is "contenteditable".
    
    * The vim keymap uses a different method for showing the normal mode cursor (fat cursor) in contenteditable: it uses `doc.markText` to mark the current character. An empty line does not have any character, so the mark does not show up.
    

    One workaround is to explicitly set the option inputStyle: "textarea" in the CodeMirror initializer. Another is to change the line in codemirror.js that says

    var ios = !edge && /AppleWebKit/.test(userAgent) && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2);
    

    to

    var ios = safari && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2);
    

    The second workaround added to 5.59.2 didn't really do the trick, and the first workaround is not good either since IMEs do not work well when the mode is textarea rather than contenteditable.

    Any other tricks? Or do we need to wait for a formal Codemirror fix of VIM invisible cursor or IMEs working in textarea mode?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions