Loading ...
Sorry, an error occurred while loading the content.

139157Emit Terminal Keycodes from within ViM

Expand Messages
  • Saad Malik
    Sep 14, 2013
      Hi All,
      I've been searching on this topic for hours but couldn't find anything relevant on the internetz.

      In VIM, map <F6> to emit/send the following Mintty terminal keycode "\e[?7727h".

      Cygwin Mintty terminal has a special mode (app escape mode) when enabled emits \eO[ (instead of regular \[) on ESC key. Using this I mapped <Esc>O[ to <ESC> which immediately exits insert mode. To enable App Escape mode for mintty, the following terminal code needs to be sent "\e[?7727h". To disable the app escape mode: "\e[?7727l".

      I've set my &t_ti = "\e[?7727h" and &t_te = "\e[?7727l". This works great--as soon as I start VIM, vim emits the t_ti code to enable Mintty app escape mode. As soon as I exit, t_te emits the app escape off code.

      However, I run into a little bit of trouble when running vim inside of tmux. If I exit Vim in a window, the app escape mode OFF is sent--then switching to another running window with ViM ALREADY running causes issues since app escape mode is off and ESC key won't generate the special \eO[ code.

      I was thinking of a simple manual step to just emit App Escape Mode ON keycode (using F6) whenever I find ESC not working properly.

      ..... half-way through writing this post I realized a simple fix .... If I execute any SHELL command from within VIM (e.g: :!echo "hellooo"), Vim will run the script and then regain control. What I just realized is that when Vim regains control--it'll emit whatever is in &t_ti --which includes my App Escape Mode ON.

      Anyway, for the sake of argument is there a Vim one liner that emits terminal keycodes from INSIDE Vim (without running an external script)?

      See the following links for more info:

      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Show all 4 messages in this topic