How do you change the default ESC to exit insert mode in LightTable's Vim? - vim

I'm posting this question largely to provide the answer I've arrived at (because I found nothing elsewhere online and see no questions asking how to do this), to hopefully save future LightTable vim users a bit of time. But I'd also like to hear about any other solutions people have found to this problem, or vim LightTable problems in general.
I've fallen in love with LightTable, but at least minimal vim support is a must before I even consider an IDE. LightTable has that. Currently, though, you're largely stuck with the default vim options and little ability to alter configuration. I would be very interested in hearing about what the future plans are in this area (you out there Chris?). Exposing a .vimrc in a local config directory, even if highly limited in functionality, would be simply awesome, but I realize its very early yet in development and largely depends on what CodeMirror can provide.
One thing I can't tolerate is having to send my pinky way up and to the left to hit the ESC key to exit insert mode. That is way too slow and requires your left fingers to leave the home row, which is never good. The way I normally handle this in vim is to map ii to exit insert mode in .vimrc. Another alternative that is there by default is to hit CTRL-[. That's better, but to me that's entering emacs chording territory and for some reason my right pinky finger almost always flubs hitting either of the bracket keys.
This is a bit of hack, but it's a tolerable work-around until better vim support comes along in LightTable/CodeMirror. I've only tested it on the latest LightTable (0.4.9), so I'm not sure how applicable it is to earlier versions (which you probably shouldn't be on anyways), or, for that matter, later versions that will come along.
There is a command option called "Vim: toggle vim mode". This turns vim on and off in an editor (or instarepl). You can bind this command to a hot-key combination via the "Settings: Change key bindings/shortcuts" command. This will open up a new tab where you can enter new key bindings on the left. The current key bindings are shown on the right.
I use SHIFT-i, within a context of :editor.keys.normal. (This means I can't use capital "I" directly in the text, but in actual practice with program editing - especially clojure - this almost never causes a problem, and if it does you can just use lower-case i and then back up and do a replace char.) This effectively makes "II" (SHIFT-i SHIFT-i) the means of exiting insert mode. The first SHIFT-i exits vim and puts you in the normal, WYSIWYG editor. The next SHIFT-i puts you back in vim, but in command mode. Voila! You've went from vim insert mode to vim command mode.
Hope this helps other LightTable vim users.

Update: I think the latest LightTable release supports this. Someone please comment if adding the following to their user.behaviors file works (user behaviors is accessible via the command pane (ctrl-space)):
[:editor :lt.plugins.vim/set-options {"enableInsertModeEscKeys" true,
"insertModeEscKeys" "jk",
"insertModeEscKeysTimeout" 200}]
Old answer:
The latest LT plugin source supports this, but has not been released yet.
To easily install it do the following:
Open your LT plugins folder, e.g. on OSX ~/Library/Application Support/LightTable/plugins/Vim/
(Optional) Save a backup of the Vim (plugin) folder somewhere else
Delete the Vim folder
Download https://github.com/LightTable/Vim/archive/master.zip
Unzip it, rename the unzipped folder to just Vim, and move/copy it to your LT Plugins folder (i.e. it is replacing the official Vim plugin that you just deleted)
Add the following options in the :editor section of your user.behaviors file:
(:lt.plugins.vim/set-options {"enableInsertModeEscKeys" true,
"insertModeEscKeys" "jk"
"insertModeEscKeysTimeout" 200})
Restart LT and you should be able to use jk (or whatever keys you set in insertModeEscKeys) to exit insert mode

CodeMirror's API is designed in such a way that it's not very complicated to add key bindings but adding support for a configuration file and extending the default key bindings to cover a larger part of Vim's feature set doesn't exactly sound like a trivial task to me. And, considering the fact that LT doesn't even have search/replace, probably something that is near the bottom of their TODO list.
That, and CodeMirror is a third party "library" on which the LT team probably doesn't have much leverage.

Related

Is there a way to view the current input source in vim?

When using vim in a non-English language environment, mistakes in mis-entering command often occur.
To prevent this, is there a way to view the current input source on the statusline?
For example, EN or JP.
like MS word bottom bar
Vim doesn't have that information so it can't expose it, which is not exactly a problem since your desktop environment already does.
If you really want to duplicate that information in your Vim status line, then you will have to find what external command to call, and then find a way to consume the information that doesn't slow Vim to a crawl because the status line is refreshed several times per second.
Now, your question is really two questions:
How to get the information?
How to show it in the statusline?
The answer to the first question depends on your desktop environment, which you didn't disclose. You will have to look around on your own, on more specialised forums.
The answer to the second question is irrelevant without an answer to the first one but you can look up :help 'statusline' and :help system() if you are curious.
Anyway, you already have the information in your desktop environment's menu bar/task bar/whatever, so why bother?
Vim has modes. In Normal mode where it is supposed to stay most of the time all commands consist of latin letters by default. Therefore, using OS level keyboard layout switch cannot be recommended. Instead, Vim has a feature called "keymap". Vim keymap is only active in Insert or Command-line mode never affecting the Normal mode.
So, Vim never cares what is your active keyboard layout on OS level and you won't expect an easy way showing it. On the other side, Vim keymap name is accessible either as b:keymap_name variable or %k format specifier for the statusline option. So it is pretty easy to add it.

Vim8 cannot delete letters

I installed a vim 8.1 on the cluster I am using in my home folder. I also installed a number of plugins including YouCompleteMe. I then made an alias so that I can open the vim easier.
However, I found that my vim cannot delete letters very well. When I am writing I can delete what I just typed. But if I move the cursor to other places, then it cannot delete letters at all, unless I type in something at first.
I am using a Scientific Linux system developed by the Fermi Lab.
How can I solve this problem?
Thanks
This sounds like the default configuration of the :help 'backspace' option. If this doesn't contain start, you cannot remove characters over the start of insertion by pressing Backspace, only what got inserted before. Removal of characters via the x or d commands (:help deleting) should always work - anywhere. Else, you have a serious misconfiguration should inspect your ~/.vimrc and re-add plugins one by one.
If you're new to Vim (and using backspace for deletion in insert mode is a typical approach of people used to other, modeless editors), you should spend 30 minutes on the vimtutor that comes with it (see :help vimtutor). Then, there are several good resources, cheatsheets, and vi / Vim tutorials out there on the net. http://vimcasts.org/ has several short entertaining episodes that go beyond the basics.
Your problem could be fixed by putting
set backspace=indent,eol,start
into your ~/.vimrc. Also have a look at :help defaults.vim; by including that instead, you'll get other goodies and recommended settings as well! (The reason for the odd defaults is backwards compatibility.)

vim spell: autoupdating suggestion-window for plain text?

I know great autocompletion plugins like YouCompleteMe for coding. I would like to have something similar for plain text files: A suggestion window (for the german language!) automatically popping up at the lets say 6th char in every word updating with each new character typed until it gets selected with ENTER or TAB else being dropped.
All I could achieve with spell is some remapping of C-x C-k to faciliate the popup, I still have to discard the autoselection with C-e which is somewhat annoying to me.
So with the power of vimscript (or some already existing plugin): Can we make this happen?
The acp.vim plugin (formerly named AutoComplPop) automatically opens the completion popup as you type. With the g:acp_completeOption configuration, you can make it use a dictionary source.
Note that the plugin still works, but hasn't seen any maintenance in the recent past. Another alternative might be neocomplete, but it (and its related plugins like neocomplcache) have also seen much turmoil.

Specific programming text editor for simple open/close editing

I'm looking for very specific text editor:
Closes on ESC, no project management or tabs
Syntax highlighting - preferably with color themes (e.g. can apply different color themes without changing C# coloring definition) or, at least, can load/save themes; support for C/C#/XML/HTML/JavaScript/etc - common MS/.NET world - out of box
Configurable keys, or: Shift-Tab shifts blocks
XML/HTML auto-completion support - well, optional
I use synplus plugin for Total Commander currently, but it has few drawbacks (e.g. crashes sometimes ;-), no auto-completion, etc).
Basically I want fast Visual-Studio-like editor that I open, do edits, and then close using ESC. I remember I tried Notepad++, etc - most of them open files in tabs, don't close on ESC... - that is, behave like IDE.
At least I've just downloaded Notepad++, it doesn't close on ESC even if I setup keybindings to do so.
Autocompletion is optional (though it is to be simple as just tags completion), what I really look for is closing on ESC, not getting in the way with all the tabs and IDE-like, and good coloring. Plus shift-tab is must have for blocks manipulation.
Update: any open-source one that I can easily tweak to close on ESC? ;-) Seems like ESC (and reasonable color highlighting) is the core requirement. I've just tried many editors - Programmer's Notepad, E, Crimson, etc - I can't set any of them to close on ESC. Any external tool to close selected program on ESC? ;-)
UPDATE: Hm, found an awesome utility for my latest thought: http://www.autohotkey.com. Easy to setup to close any window on ESC (as well as many other tricks). Seems like the most tough requirements is gone - I can use ANY text editor ;-)
You could use Emacs 23's new server functionality to make it start fast, and then configuring it to use whatever key bindings you like is trivial.
You can try Notepad2. I like it for the same reasons - close on Escape and syntax highlighting. Very light and fast to start.
So, I close this because I've found a fix for the main issue with ESC key: http://www.autohotkey.com. Here's a sample script that do the trick for e text editor:
SetTitleMatchMode, 3
#IfWinActive ahk_class wxWindowClassNR
Esc::WinClose, A
return
Now I'm free to choose from wide range of editors.
vim?
Sure, it doesn't use esc to quit, but :wq is pretty quick.
Given you've got rid of the ESC issue I'd suggest taking a look at jedit. It's fairly lightweight (well, compared to a full IDE), nicely configurable and runs on any OS. Generally one of the first things I install on any box I'm going to be working on because I know I'll always have a familiar environment.
With a bit of tweaking the Zeus editor can be configure to behave this way.
To get the editor to close on ESC the keyboard mapping will need to be edited and the ESC key rebound to the FileExit function.
The current version of Notepad++ (6.4.5) does let you close files using Esc. To do this you have to set Esc as the Exit key (Number 19) by using Settings | Shortcut Mapper.

What Vim features are missing in Emacs with Viper and Vimpulse?

There are important features of Emacs which are missing in Vim, such as the comint mode, and there are no scripts/plugins which can replace them.
There are also benefits of Vim over Emacs, such as modal editing and generally better default shortcuts. However, Viper mode gets me both. Vimpulse also enables visual mode.
Unfortunately, no mode can make Emacs work as fast as Vim.
So I mostly learned Vim-in-Emacs. What Vim features am I missing?
I'm a regular vim user but not an emacs user and haven't used vimpulse to confirm this.
But browsing the vimpulse code below I see no mention of text objects.
http://www.emacswiki.org/cgi-bin/wiki/vimpulse.el
Vim introduced some very useful idioms for selection and movement that aren't in regular vi
cat 'cut around tag' for xml/html tags
diw 'delete in word'
di( di" delete text within a "" () etc.
in the vim help see :he text-objects for more.
Unfortunately, no mode can make Emacs work as fast as Vim.
If you mean that the emacs startup time is poor, you can cut it down dramatically by having an emacs session permanently open, and use gnuclient/emacsclient whenever you need to edit a file.
http://www.emacswiki.org/emacs/GnuClient
One vi feature that I miss in emacs is the . (dot) command that repeats the last edit. There is dot-mode.el which implements C-. to simulate this but it didn't always work for me (I am not proficient in elisp to figure out why).
Even viper doesn't implement this command exactly like vi does (last time I checked), and even if it does, I don't think that is enough for me to start using viper.
To get a complete list of what vimpulse may be missing type
:helpgrep not in Vi
Every feature in the help that is not vi compatible will be listed.
Theres about 700 matches.
Of course there will be a lot of duplicated functionality
Vi motion everywhere - in Vi you can always navigate using the same shortcuts, whether you are inside a directory listing, a help file, a write only file or something you're allowed to edit.
Correct visual and delete behaviour - very similar to emacs marking but idiomatically different, so difficult for a Vi user to retrain. If you're already used to the emacs marking you're not really missing anything.
Correct escape behaviour - should cancel all other modal activity and return you to command mode. Again, if you're comfortable in emacs you're probably used to having modal inputs and such anyway.
The obvious chestnuts about Vi being deployed on every nix system in the world (Gentoo purists correct me?) - not a very strong argument in my eyes anyway.
Those are the ones that sprang out during my use of emacs+viper.
Vim macros don't seem to work with viper/vimpulse:
Vim macros don't work when using viper + vimpulse in Emacs
(Btw, the killer emacs feature that makes me care about vim/vimpulse is that different frames can edit the same file. It's like having a split where the two pieces can be in different windows. If anyone knows how to accomplish that in vim, you'd be my hero.)
Incremental search using / and ? is missing.
Being a lover of emacs as an OS and vi as an input model, naturally I wanted to love viper. However within two seconds of using it I had to give it up: viper does not support C-[ as a substitute for the escape key–which is an essential shortcut for the most frequently used command in vi.

Resources