Skip to content

Handle delay when exiting into vim normal mode #216

@echasnovski

Description

@echasnovski

Hello, @randy3k! I wanted to share my problem, its current workaround, and ask for any suggestions and possibilities of new radian settings.

By default, when using "vim" editing mode there is a rather long delay when exiting from insert into normal mode after hitting <Esc> key. It is tolerable if no radian.escape_key_map is defined and long otherwise.

I believe, it is present in order to enable escape_key_map functionality. However, I use those keymappings with <Alt> key so I don't really need any delay when hitting <Esc>. I didn't find any setting in radian which can help with this.

My current workaround is as follows. As radian uses Python's 'prompt_toolkit', there is a way to modify that delay. Currently it is defined by ttimeoutlen and timeoutlen properties of Application class. Their default values are 0.5 and 1 seconds. After experimenting, it seems that delay of 0.5 is "used" when no escape_key_map is defined and 1.5 (0.5+1) otherwise. Inspired by this comment, I implemented the following workaround (which is added to '.radian_profile'):

options(
  radian.editing_mode = "vim",
  radian.on_load_hooks = list(function() {
    getOption("rchitect.py_tools")$attach()

    radian <- import("radian")
    app <- radian$get_app()$session$app

    # Modify timeout lengths (in seconds): time to wait after pressing <Esc>
    # for another key pressing. Very useful to reduce delay when going in
    # Normal mode under "vim" editing mode.
    app$ttimeoutlen <- 0
    # This shouldn't be too small, as it is used when dealing operator sequence
    # in normal mode
    app$timeoutlen  <- 0.25
  })
)

Currently this works for me. Is there any chance of getting "official" radian settings which can help with this issue? The ultimate solution would be two settings: enabling <Alt> key mappings instead of <Esc> and those [t]timeoutlens, but I don't believe both of them are possible, are they?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions