How to change the default ESC to exit insert mode in LightTable Vim?

I am posting this question mainly to provide an answer that I came up with (because I didn’t find anything elsewhere on the Internet and I don’t see any questions asking how to do this) in order to hope that there will be a little bit of future users of LightTable vim early. But I would also like to hear about any other solutions that people have found for this problem, or about problems with Vim LightTable in general.

I fell in love with LightTable, but at least minimal vim support is a must before I even consider the IDE. LightTable has it. Currently, however, you pretty much stick to the default vim options and little ability to change the configuration. I would be very interested to know what are the plans for the future in this area (are you Chris there?). Finding .vimrc in the local configuration directory, even if it is very limited in functionality, would be awesome, but I understand it very early in development and depends a lot on what CodeMirror can provide.

One thing I can't stand is to send my little finger up and to the left to press the ESC key to exit insert mode. This is too slow and requires your left fingers to leave the home bar, which is never good. The way I usually handle this in vim is to display ii to exit insert mode in .vimrc. Another alternative, which is by default, is to use CTRL- [. It’s better, but for me, the input to emacs regulates the territory, and for some reason my right little finger almost always pounces on any of the keys of the bracket.

It's a bit of a hack, but it's an acceptable job until better support for vim appears in LightTable / CodeMirror. I tested it only on the latest version of LightTable (0.4.9), so I'm not sure how much this applies to earlier versions (which you probably shouldn't be anyway) or, for that matter, later versions, which will come.

There is a command option "Vim: toggle vim mode". This enables and disables vim in the editor (or instarepl). You can associate this command with a hotkey combination using the "Settings: Change Key Bindings / Shortcuts" command. This will open a new tab in which you can enter new key bindings on the left. The current key bindings are shown on the right.

I use SHIFT-i in context: editor.keys.normal. (This means that I cannot use the capital "I" directly in the text, but in practice with editing the program - especially clojure - this almost never causes problems, and if so, you can simply use the lower case i and then do a backup copy and replace char.) This actually makes "II" (SHIFT-i SHIFT-i) a means of exiting paste mode. The first SHIFT-i exits vim and puts you in a regular WYSIWYG editor. The next SHIFT-i returns you to vim, but in command mode. Voila! You have switched from vim input mode to vim command line mode.

We hope this helps other LightTable vim users.

+4
source share
3 answers

Update: I think the latest version of LightTable supports this. Someone please comment if you add the following files to your user.behaviors files (user behavior is available through the command bar (ctrl-space)):

 [:editor :lt.plugins.vim/set-options {"enableInsertModeEscKeys" true, "insertModeEscKeys" "jk", "insertModeEscKeysTimeout" 200}] 

Old answer:

The latest source plugin for LT supports this, but has not yet been released.

To easily install it, follow these steps:

  • Open your LT plugins folder, for example. on OSX ~/Library/Application Support/LightTable/plugins/Vim/
  • (Optional) Save a backup copy of the Vim folder (plugin) somewhere else.
  • Delete Vim folder
  • Download https://github.com/LightTable/Vim/archive/master.zip
  • Unzip it, rename the unzipped folder only to Vim and move / copy to the LT Plugins folder (i.e. replace the official Vim plugin that you just deleted).
  • Add the following parameters to :editor your user.behaviors file: (:lt.plugins.vim/set-options {"enableInsertModeEscKeys" true, "insertModeEscKeys" "jk" "insertModeEscKeysTimeout" 200})
  • Reboot LT and you can use jk (or any keys that you set in insertModeEscKeys) to exit insert mode
+4
source

The CodeMirror API is designed in such a way that it’s not very difficult to add key bindings, but adding support for the configuration file and expanding the default key bindings to cover most of the Vim feature set doesn't seem like a trivial task for me. And, given the fact that LT doesn’t even have a search / replace, perhaps something similar to the bottom of their TODO list.

This, and CodeMirror, is a third-party “library” on which the LT team probably doesn't have much leverage.

+3
source

For Windows users, your LT plugin folder is located in the hidden AppData folder located in your user directory. e.g. C:\Users\_username_\AppData\Local\LightTable

-2
source

Source: https://habr.com/ru/post/1481222/


All Articles