News for hackers. Stuff that matters.
Re:Escape key alternatives in Vim by K0nserv on Sunday December 04, 2016 @01:26PM (#13101036)
I've been using jk for quite some time now. It's definitely my favourite improvement over stock vim. You can sort of roll your fingers with your right hand index and middle finger which makes it super fast.
Re:Escape key alternatives in Vim by mpobrien on Sunday December 04, 2016 @12:59PM (#13100904)
Remapping caps lock to ESC has been my preferred method for this, I'd suggest giving it a try!
Re:Escape key alternatives in Vim by falcolas on Monday December 05, 2016 @11:41AM (#13106663)
Better, IMO, to use it as a control key (you can do so much with the control key inside a terminal). Of course, why not both?

http://www.economyofeffort.com/2014/08/11/beyond-ctrl-remap-...

Re:Escape key alternatives in Vim by Tempest1981 on Sunday December 04, 2016 @01:38PM (#13101113)
A coworker with RSI mapped a foot switch to Escape. Something like this: https://www.kinesis-ergo.com/shop/advantage-3-pedal/
Re:Escape key alternatives in Vim by dongslol on Sunday December 04, 2016 @03:02PM (#13101498)
I've thought of using one of those to map a parenthesis to each foot, for Lisp.
Re:Escape key alternatives in Vim by bilalq on Sunday December 04, 2016 @03:45PM (#13101691)
The article mentions that you can set custom mappings to escape and uses this as an example:

    imap jj <Esc>
If you're interested in doing that, I'd strongly recommend you never do a plain `imap` and instead always do `inoremap` (this advice applies to `nmap`, `vmap`, and the like as well). The difference is that the noremap variant is non-recursive [0].

Also, since we're on the subject of escape alternatives, I may as well mention mine. It really bothers me that exiting insert mode moves your cursor back a space. To remedy that, I've got a custom mapping that escapes and them jumps to the mark at which insert mode last was [1]. The mapping is:

    inoremap jj <Esc>`^
[0]: http://learnvimscriptthehardway.stevelosh.com/chapters/05.ht...

[1]: http://vimdoc.sourceforge.net/htmldoc/motion.html#`^

Re:Escape key alternatives in Vim by EduardoBautista on Sunday December 04, 2016 @04:57PM (#13102000)
I'll go ahead and update it. Thanks for the info!
Re:Escape key alternatives in Vim by simplicio on Sunday December 04, 2016 @01:08PM (#13100946)
I use alt-[keystroke], which changes to normal mode and executes [keystroke]. So if the first command I intend to execute in normal mode is simple, I get that plus the mode change in one keystroke. If the command is complicated, I just use alt-l (moves the cursor one space) which I find easier to hit than ctrl-[ or esc.

As a bonus, it works in readlines vi mode as well.

Re:Escape key alternatives in Vim by threatofrain on Sunday December 04, 2016 @12:58PM (#13100895)
I'm surprised of no mention of mapping <esc> to <caps> -- it's such a sweet modification to Vim. I'd do it regardless of Apple's touchbar announcement.
Re:Escape key alternatives in Vim by ErikCorry on Sunday December 04, 2016 @01:08PM (#13100944)
I haven't done this because I'm trying to stop chording: pressing two keys simultaneously with the same hand. I'm pretty sure it causes RSI (try Googling chording and RSI).

When I have to type all caps, I find myself chording a lot. The alternative is to always use the right shift for capital letters on the left and vice versa, but that doesn't work well for all caps words. Therefore I'm trying to learn to actually use caps lock.

Admittedly it's not going very well

Re:Escape key alternatives in Vim by chubot on Sunday December 04, 2016 @01:12PM (#13100973)
Vim solution: type in all lower case, then select what you just typed and press ~.

Admittedly it doesn't help for non-Vim applications, but I don't find myself typing all caps outside Vim very often. It's usually to type something like FOO_BAR, but then you can just type FO<Ctrl-N> and that usually works.

Re:Escape key alternatives in Vim by typicalrunt on Sunday December 04, 2016 @01:37PM (#13101105)
~ is for one character. If you have a word you want in caps, do gUw. For lowercase, it's guw.
Re:Escape key alternatives in Vim by chubot on Sunday December 04, 2016 @01:40PM (#13101121)
~ works under visual selection.
Re:Escape key alternatives in Vim by falcolas on Monday December 05, 2016 @11:38AM (#13106636)
Or for a string, gUi"

"go Uppercase inside double quotes"

Re:Escape key alternatives in Vim by michaelmrose on Sunday December 04, 2016 @01:31PM (#13101072)
How often do you type in all caps and why can't you bind another key or key combo to caps? Regarding chording I use the following strategy.

I use i3wm which lets you define your own modes and bind arbitrary keys to commands. Effecting a mode is a set of effective bindings wherein one binding in one mode can make a different mode active letting you define vim like sequences of keys to accomplish a goal.

I use xcape which lets you have a key produce a different key when pressed vs used as a modifier. I use the key produced by tapping right shift to start operations with my window manager. Eg vot opens appkey t in this case terminal in a vertical split. In Emacs I use the key produced by tapping left shift to start operations as a leader key eg to correct mispellings I use left shift c w.

I remap caps to escape. I would also just map escape to caps but some games seem to ignore what you have mapped and require you to press the real escape key to get out of a menu. So lacking an optimal key I just map right shift -> c to caps.

Re:Escape key alternatives in Vim by valbaca on Monday December 05, 2016 @04:39PM (#13109925)
I use "kj" for escape, "lkj" for escape-and-save, and ";lkj" for escape-and-save-and-quit since I can roll my fingers faster that way that doing "jk" or "jj"

It also has the advantage of usually being a no-op in visual mode (kj moves up, then moves down). "jk" has the same advantage. Whereas "jj" will move you down.

I also have my caps-lock key mapped to escape.

(EDIT: learning from bilalq https://news.ycombinator.com/item?id=13101691)

    "during insert, kj escapes, `^ is so that the cursor doesn't move
    inoremap kj <Esc>`^
    "during insert, lkj escapes and saves
    inoremap lkj <Esc>`^:w<CR>
    "during insert, lkj escapes and saves and QUITS
    inoremap ;lkj <Esc>:wq<CR>
Re:Escape key alternatives in Vim by red2awn on Sunday December 04, 2016 @01:03PM (#13100927)
I mapped <esc> to jk, though I don't use vim that often.
Re:Escape key alternatives in Vim by cygned on Sunday December 04, 2016 @02:00PM (#13101224)
That's my setup.

    vnoremap <C-c> <Esc>
    inoremap <C-c> <Esc>
    inoremap <Esc> <nop>
    vnoremap <Esc> <nop>
Re:Escape key alternatives in Vim by IgorPartola on Sunday December 04, 2016 @01:59PM (#13101219)
Off topic: I love vim and use it for everything from writing love notes to assembly. Lately I've picked up using Vue.js with the new .vue files using ES6. What code highlighting plugin have y'all successfully used for the JS/ES portion of the file that does highlighting well and doesn't just stop working if you scroll up and down in the file? It's driving me a little batty.
Re:Escape key alternatives in Vim by ufmace on Sunday December 04, 2016 @04:03PM (#13101755)
The stock Javascript stuff works all right for me. After just tracking down a problem I was having with indention that turned out to be a dumb line in my .vimrc, I'd suggest doing a standard troubleshoot - take out all of your extensions and your .vimrc and see if it still does it. If it stops, re-enable stuff until you figure out exactly what's causing the problem.
Re:Escape key alternatives in Vim by aeosynth on Monday December 05, 2016 @11:33AM (#13106586)
There is a vim-vue plugin: https://github.com/posva/vim-vue

I'm getting by with the stock html syntax:

    au BufNewFile,BufRead *.vue set filetype=html
Re:Escape key alternatives in Vim by IgorPartola on Monday December 05, 2016 @03:45PM (#13109359)
My current plugin list is:

    Bundle 'scrooloose/syntastic'
    Plugin 'tmhedberg/SimpylFold'
    Plugin 'ipartola/igor-vim'
    Plugin 'othree/yajs.vim'
    Plugin 'mxw/vim-jsx'
    Plugin 'leafgarland/typescript-vim'
    Plugin 'posva/vim-vue'
    Plugin 'bronson/vim-trailing-whitespace'
Re:Escape key alternatives in Vim by oinksoft on Sunday December 04, 2016 @04:21PM (#13101846)
Re:Escape key alternatives in Vim by IgorPartola on Monday December 05, 2016 @03:44PM (#13109340)
That's the one I'm using.
Re:Escape key alternatives in Vim by kough on Sunday December 04, 2016 @01:33PM (#13101082)
Ctrl-c and Ctrl-[ are my favorite -- once you remap caps lock to control (so that control is where it was when these interfaces were designed), you have a simple, 2-hand chorded escape with minimal stress on the keys.

Does anyone here remap backspace to something else? My right wrist has been particularly RSI sensitive in the last month or so and I've noticed that reaching for backspace tends to set it off.

Re:Escape key alternatives in Vim by ErikCorry on Sunday December 04, 2016 @05:06PM (#13102028)
I have backspace on my left thumb: https://www.kinesis-ergo.com/shop/advantage2/

Highly recommended for Linux or Windows desktop computers if you have RSI trouble. A bit unwieldy for laptops though. I use both and switching isn't a big issue (unlike switching national keyboards, which drives me crazy). It doesn't quite have enough modifiers for Mac - can't have both left and right versions of shift, alt, ctrl and command.

Vi users have to swap the up-arrow and the down-arrow since they use the same fingers as j and k, but reversed. However, it's pretty easy to remap, and it happens in the keyboard so it works everywhere.

Re:Escape key alternatives in Vim by ibiza on Sunday December 04, 2016 @01:31PM (#13101070)
You can reduce the lag of using <Esc> with:

    set timeout timeoutlen=1000 ttimeoutlen=10
Re:Escape key alternatives in Vim by kough on Sunday December 04, 2016 @01:34PM (#13101084)
Very cool trick, thanks for sharing. Is there any reason I wouldn't want this?
Re:Escape key alternatives in Vim by jks on Sunday December 04, 2016 @01:38PM (#13101109)
Arrow and function keys are mapped to escape sequences, so if you use vi over a slow or unreliable connection your arrow keys could randomly get interpreted as escape followed by some commands.
Re:Escape key alternatives in Vim by z1mm32m4n on Sunday December 04, 2016 @03:13PM (#13101558)
timeoutlen is also used by leader key combos, and things like gg, fx, etc. If you drop your timeoutlen, make sure you can still combo these fast enough for them to register.
Re:Escape key alternatives in Vim by ErikCorry on Sunday December 04, 2016 @01:03PM (#13100920)
jk works pretty well. Actually faster to type than jj
Re:Escape key alternatives in Vim by nikkisnow on Sunday December 04, 2016 @02:01PM (#13101225)
I prefer to use <,><e> to escape out of insert mode.