I need to be able to run vi on a machine that I access through Citrix lite in the browser. However I've come across a number of problems because of conflicts around esc and ctrl+w.

Specifically, although I am trying to have vi revert to command mode or another window operation, the browser intercepts esc as having by focusing to the URL bar or leaving fullscreen, and ctrl+w to close the tab. Maybe there is some kind of remapping plugin for either chrome or firefox that addresses this, or is there any other strategy that vi users adopt?

1 Answer 1


Maybe there is some kind of remapping plugin for either chrome or firefox that addresses this?

Regarding Citrix, Citrix Lite and the browser, you'll have more luck asking about it on Superuser, so I suggest you post a question there for a solution from that front.

Is there any other strategy that vi users adopt?

You should be able to use Vim mappings to work around this issue, remapping keys that don't conflict with your browser to replace or supplement the ones that don't work for you.

For the "Escape" key, you usually need it when you're in Insert mode, so it might be tricky to find a mapping for it, since most keystrokes are typically inserted... There is a common practice of using the sequence "jk" as a replacement for "Escape", since the "jk" sequence usually results in no motion in Normal mode (move down one line, then back up one line) and the sequence "jk" is uncommon in most languages.

You can create a mapping from "jk" to do the same as the "Escape" key in Insert mode with:

:inoremap jk <Esc>

You can add this same command into your _vimrc file. In that case, you can omit the : from the beginning of the line. (See also "Training your fingers" from "Learn Vimscript The Hard Way" by Steve Losh for more on the motivations for the jk mapping, if you're interested.)

Another alternative is to remap a keystroke that doesn't usually produce output, such as a key sequence involving the "Control" key, or perhaps one of the F-keys such as F1.

There are also two options that might work out of the box, without any special configuration. One is that the sequence Ctrl+[ is equivalent to "Escape" in Vim. It's possible that your browser in your platform is not trapping Ctrl+[ the same way it's catching Esc, so if that's the case, you could use Ctrl+[ on Vim through Citrix. If this works, it will be exactly equivalent to the "Escape" key.

Another option is using Ctrl+C. This keystroke is also used in Vim to leave Insert mode, so you can also typically use Ctrl+C instead of Esc. Note that this is not exactly equivalent to the behavior of "Esape", there are some cases where the behavior of Ctrl+C and Esc are slightly different. But the difference is quite small, so in most cases you should be fine. (As one example, if you use a "count" with the command you use to enter Insert mode, when you leave it with Esc the count will be respected and the insertion will be repeated, while Ctrl+C will cancel the count and simply leave Insert mode without executing the repetition.)

Regarding Ctrl+W, for window operations, you can use a simple Normal mode mapping. One that's easy to remember and convenient is to use <Leader>w. The default configuration has <Leader> set to \, the backslash key. You can configure such a mapping with:

:nnoremap <Leader>w <C-w>

With this mapping in place, you can then use \, w wherever you were using Ctrl+W. For example, to switch to the next window in the list, use \, w, w. To switch to the window below this one, \, w, j. To move the current window, turn it into the leftmost window in the display, \, w, H. And so on.

Same as above, you can make this setting permanent by adding it to your _vimrc, in which case you can omit the initial :, it's not needed in that context.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.