You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 6, 2018. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 6, 2018. It is now read-only.
I've seen this as well. I usually map fj to escape in vim, however doing so in vim mode doesn't give the expected behavior. The first time 'f' is pressed, it always interprets it as a shortcut and waits on the rest to be entered. If something else is entered that isn't 'j' in this case then it just prints that out and continues on its marry way. In order to enter 'f' normally in my case I have to type it twice.
The vim style behavior is to have a short timeout in which, if the shortcut isn't completed the typed letters are printed. I have the feeling that this is more of an atom issue than a plugin issue though so I fear it'll be hard to change.
This completely worked for me when I thought based on #129 that it was still impossible in Atom. Only caveat was hitting jj was canceling visual mode, not just insert mode, but that was an easy fix.
I have been unable to get jj to work for typing "j" and also using "jj" to get me out of command mode. :(
I feel this shouldn't be so difficult. I have seen people reference a "timeout", but have been unable to find this anywhere in the settings for either Vim Mode nor Atom.
Edit: I just re-checked the init.coffee and noticed a misspelling... works now! Woohoo...
@BallisticPain where did you find the misspelling? I have tried and tried and I can't get jj to work. It's the only thing that prevents me from using atom, I'm just to used to my vim settings. I'm on a OSX 10.10
@pelachile, I'll copy and paste below what I have that's working. I use jj constantly and it was imperative that I got it working as well so I fully understand your frustration.
I personally mis-spelled a portion of the ~/.atom/init.coffee script. I didn't copy and paste, I just typed it in.
# Your init script## Atom will evaluate this file each time a new window is opened. It is run# after packages are loaded/activated and after the previous editor state# has been restored.## An example hack to make opened Markdown files always be soft wrapped:## path = require 'path'## atom.workspaceView.eachEditorView (editorView) -># editor = editorView.getEditor()# if path.extname(editor.getPath()) is '.md'# editor.setSoftWrap(true)#atom.workspaceView.command'insert-incomplete-keybinding', (e)->ifoe=e.originalEvent&&e.originalEvent.originalEventchar=String.fromCharCode(oe.which)
char=char.toLowerCase() unlessoe.shiftatom.workspace.activePaneItem.insertText(char)
I misspelled the .workspace portion.
Here's my ~/.atom/keymap.cson (I was originally modifying the one in the package directly, and this wasn't working as well as modifying my home directory version)...
# Your keymap## Atom keymaps work similarly to stylesheets. Just as stylesheets use selectors# to apply styles to elements, Atom keymaps use selectors to associate# keystrokes with events in specific contexts.## You can create a new keybinding in this file by typing "key" and then hitting# tab.## Here's an example taken from Atom's built-in keymap:## '.editor':# 'enter': 'editor:newline'## '.workspace':# 'ctrl-P': 'core:move-up'# 'ctrl-p': 'core:move-down'#'.editor.vim-mode.insert-mode':'j':'insert-incomplete-keybinding''.vim-mode.insert-mode:not(.mini)':'j j':'vim-mode:activate-command-mode'
One thing I will also note here is that I believe the order of these two insertions matters. The other note is that if you want to type a 'j' while in insert mode, type it and then the next letter and they'll both appear. Otherwise you must wait for the timeout to occur to see the 'j' appear.
Atom seems to have a new process to add custom commands. I have been playing with atom for all of 10 mins, but in order to achieve this functionality without using the deprecated atom.workspaceView.command I implement the insert-incomplete-keybinding as such:
I was still seeing odd delays with the methods described above and so I implemented things in a slightly different way. Note that I prefer to use kj to exit insert mode rather than jk or jj, but you should be able to modify this for your own approach.
While this isn't quite as flexible (in terms of being able to map different keys without changing the command that's executed), there are no "timeout" related issues or visual delays in not having the j (or in my case, k) char appear on the screen until the next keypress. This also avoids issues related to Atom "eating" the first char of your mapping, which can happen with other approaches.
edit: the word should have been "preceded" not "proceeded". edit2: changed .editor to atom-text-editor to resolve Atom 1.0 deprecation warning edit3: 22July2015 - Changed vim-mode:activate-command-mode to vim-mode:activate-normal-mode for compatibility with v.56+
Reacted by Rahul Roy, Lane Harrison, elhachimi, Bram de Haan, Kendall Roth, Bhaskar, Lawson J., Dan Gieschen Knutson and Alberto Silva
Reacted by Jesse Leite, Rob Wettlaufer, Kamil Mugutdinov, Bram de Haan, Bhaskar and Lawson J.
Reacted by Emmanuel Herrero , mikeebert, Bram de Haan, Bhaskar, Shoichi Aizawa, Lawson J., Aaron Cruz and Alvaro Rubio-Garcia
The best and simplest until this is supported natively by Atom:
Is the one by: @Robert-Wett
because the the one by @garcg doesn't work if yo wanna map escape to something like =>
, ,
So, the final solution is as @Robert-Wett except he didn't add escape for visual mode in the mapping:
It's still not perfect because it just wait for the second letter for ever....!!!
it should be just a half a second or so then inserts the char and return...
But actually non of the snippets posted in this thread is working for me. Solutions with init script functions, solutions without it... no chance to make it operational.
I have tried reinstallation, disabling the other plugins etc . without any success. An I dunno how to debug it.
@kylesezhi and @Yohanna that keymap always worked. The issue is with the delay when typing anything like "jam" or "jesse". There's a bad delay after hitting that j key while the keymap listener is waiting for a possible k to follow.
Other vim emulators do their check after hitting the second k input. The emulator then checks the previous key to see if it was a j, and if so enters vim mode. This allows the vim emulator to handle the same j k key mapping without that delay.
Exactly. Avoiding the delay is precisely what my post above (and PR to have
this added to the Readme) is all about.
One step further that i think is worth considering is to just add the code
to the package itself and allow the user to specify their preferred two-key
mapping to exit insert mode via the vim-mode config screens. It's debatable
as to whether something like this belongs in the config gui, but mapping a
sequence like this is such a common thing that it could be justified.
(Assuming, of course, adding this to the config would allow users to skip
the business of adding the custom function to the init script.)
To be perfectly honest I'm not a daily Atom user so can't justify looking
into building this right now. When I do use Atom I'd like the mappings to
work properly, which is what my approach allows.
Other vim emulators do their check when you hit the second k input. When k
is hit, the emulator checks the previous key to see if it was a j, and if
so enters vim mode. This allows the vim emulator to handle the same key
mapping without delay.
—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub #334 (comment)
While that's true, it's also true in Vim proper. Probably why the "official" way to leave insert mode is ESC instead of some combination of letters you may want to type. :)
Simple enough to add one additional check to the code to see if you might be typing something like 'sockjs' (look for a 'c' before the 'k') if this hits you a lot.
I do have a PR open (#946) to try and get some mention of this in the Readme. Anyone interested in reviewing it and merging and/or otherwise getting it documented? AFAIK, this is still the "best" method of remapping ESC in Atom.
Activity
just-be-dev commentedon Jul 16, 2014
I've seen this as well. I usually map fj to escape in vim, however doing so in vim mode doesn't give the expected behavior. The first time 'f' is pressed, it always interprets it as a shortcut and waits on the rest to be entered. If something else is entered that isn't 'j' in this case then it just prints that out and continues on its marry way. In order to enter 'f' normally in my case I have to type it twice.
The vim style behavior is to have a short timeout in which, if the shortcut isn't completed the typed letters are printed. I have the feeling that this is more of an atom issue than a plugin issue though so I fear it'll be hard to change.
garcg commentedon Jul 24, 2014
It seems the timeout after the first key press is there, it only needs a fallback to insert the text into the editor.
I've found a workaround adding the following to the user config.
This is for mapping
j kas escape:~/.atom/keymap.cson:~/.atom/init.coffee:Although, I don't know how this could be fixed in the vim package.
just-be-dev commentedon Jul 28, 2014
It's good to know that it's doable though. I might explore a bit and see if I can come up with a solution.
philk commentedon Sep 2, 2014
This completely worked for me when I thought based on #129 that it was still impossible in Atom. Only caveat was hitting
jjwas canceling visual mode, not just insert mode, but that was an easy fix.Thanks, now I can use Atom without having to change my habits 😃
BallisticPain commentedon Jan 8, 2015
I have been unable to get jj to work for typing "j" and also using "jj" to get me out of command mode. :(
I feel this shouldn't be so difficult. I have seen people reference a "timeout", but have been unable to find this anywhere in the settings for either Vim Mode nor Atom.
Edit: I just re-checked the init.coffee and noticed a misspelling... works now! Woohoo...
Thanks!
J
pelachile commentedon Jan 10, 2015
@BallisticPain where did you find the misspelling? I have tried and tried and I can't get jj to work. It's the only thing that prevents me from using atom, I'm just to used to my vim settings. I'm on a OSX 10.10
BallisticPain commentedon Jan 12, 2015
@pelachile, I'll copy and paste below what I have that's working. I use jj constantly and it was imperative that I got it working as well so I fully understand your frustration.
I personally mis-spelled a portion of the ~/.atom/init.coffee script. I didn't copy and paste, I just typed it in.
I misspelled the .workspace portion.
Here's my ~/.atom/keymap.cson (I was originally modifying the one in the package directly, and this wasn't working as well as modifying my home directory version)...
One thing I will also note here is that I believe the order of these two insertions matters. The other note is that if you want to type a 'j' while in insert mode, type it and then the next letter and they'll both appear. Otherwise you must wait for the timeout to occur to see the 'j' appear.
I hope this helps,
Jarvis
JacobHTran commentedon Feb 18, 2015
Atom seems to have a new process to add custom commands. I have been playing with atom for all of 10 mins, but in order to achieve this functionality without using the deprecated atom.workspaceView.command I implement the insert-incomplete-keybinding as such:
rdlugosz commentedon Mar 24, 2015
I was still seeing odd delays with the methods described above and so I implemented things in a slightly different way. Note that I prefer to use
kjto exit insert mode rather thanjkorjj, but you should be able to modify this for your own approach.While this isn't quite as flexible (in terms of being able to map different keys without changing the command that's executed), there are no "timeout" related issues or visual delays in not having the
j(or in my case,k) char appear on the screen until the next keypress. This also avoids issues related to Atom "eating" the first char of your mapping, which can happen with other approaches.Note that using the
event.abortKeyBinding()is the preferred way to jump out of your key bindings and let the keystroke pass through to the editor (see: https://atom.io/docs/api/v0.187.0/KeymapManager).edit: the word should have been "preceded" not "proceeded".
edit2: changed
.editortoatom-text-editorto resolve Atom 1.0 deprecation warningedit3: 22July2015 - Changed
vim-mode:activate-command-modetovim-mode:activate-normal-modefor compatibility with v.56+Robert-Wett commentedon Mar 25, 2015
+1 @rdlugosz - working great for me, using
jkto exit insert mode. For the lazy:jesseleite commentedon May 6, 2015
It should be as easy as:
Unfortunately, it's not. Small things like this keep me using Sublime. I'm excited about Atom's future though.
ahmadseleem commentedon May 14, 2015
The best and simplest until this is supported natively by Atom:
Is the one by: @Robert-Wett
because the the one by @garcg doesn't work if yo wanna map escape to something like =>
So, the final solution is as @Robert-Wett except he didn't add escape for visual mode in the mapping:
It's still not perfect because it just wait for the second letter for ever....!!!
it should be just a half a second or so then inserts the char and return...
ahmadseleem commentedon May 14, 2015
Like:
I know it's extremely rare that you would need to type jj or jk or ,, or whatever alike.
But, just incase
bronson commentedon May 21, 2015
Is this a dupe of #221?
84 remaining items
martomes commentedon Feb 18, 2016
@rdlugosz No, i mean this snippet:
But actually non of the snippets posted in this thread is working for me. Solutions with init script functions, solutions without it... no chance to make it operational.
I have tried reinstallation, disabling the other plugins etc . without any success. An I dunno how to debug it.
martomes commentedon Feb 18, 2016
@rdlugosz well... only solution which works for me is upgrade to beta version (1.6.0-beta4)
kylesezhi commentedon Feb 19, 2016
I have 1.5.3 and this keymap works for me:
Note that I have a linebreak after the first colon and the second line is tabbed in.
Yohanna commentedon Mar 17, 2016
@kylesezhi Your kemap worked for me, thanks!
For the record, I'm using v.
1.5.4jesseleite commentedon Mar 17, 2016
@kylesezhi and @Yohanna that keymap always worked. The issue is with the delay when typing anything like "jam" or "jesse". There's a bad delay after hitting that
jkey while the keymap listener is waiting for a possiblekto follow.Other vim emulators do their check after hitting the second
kinput. The emulator then checks the previous key to see if it was aj, and if so enters vim mode. This allows the vim emulator to handle the samej kkey mapping without that delay.rdlugosz commentedon Mar 17, 2016
Exactly. Avoiding the delay is precisely what my post above (and PR to have
this added to the Readme) is all about.
One step further that i think is worth considering is to just add the code
to the package itself and allow the user to specify their preferred two-key
mapping to exit insert mode via the vim-mode config screens. It's debatable
as to whether something like this belongs in the config gui, but mapping a
sequence like this is such a common thing that it could be justified.
(Assuming, of course, adding this to the config would allow users to skip
the business of adding the custom function to the init script.)
To be perfectly honest I'm not a daily Atom user so can't justify looking
into building this right now. When I do use Atom I'd like the mappings to
work properly, which is what my approach allows.
On Thursday, March 17, 2016, Jesse Leite [email protected] wrote:
kylesezhi commentedon Mar 18, 2016
Thanks for that explanation, @jesseleite !
I agree - checking after the
kinjkwould be an improvement on the current way the system works. I'd love to see this in a future build of Atom.jesseleite commentedon Mar 18, 2016
Until then, you can add @rdlugosz's solution above to your init script and keymap :)
denysdovhan commentedon May 6, 2016
Yep, but it still doesn't work well for non-american keyboards.
Khangeldy commentedon May 16, 2016
After remap to
k j. It is hard to import sockjsmugukamil commentedon Jun 25, 2016
@denysdovhan Yes it is... :(
rdlugosz commentedon Oct 5, 2016
While that's true, it's also true in Vim proper. Probably why the "official" way to leave insert mode is
ESCinstead of some combination of letters you may want to type. :)Simple enough to add one additional check to the code to see if you might be typing something like 'sockjs' (look for a 'c' before the 'k') if this hits you a lot.
I do have a PR open (#946) to try and get some mention of this in the Readme. Anyone interested in reviewing it and merging and/or otherwise getting it documented? AFAIK, this is still the "best" method of remapping ESC in Atom.
glrodasz commentedon Oct 13, 2016
@denysdovhan Why it is that? I have an non-american keyboard and works well.
denysdovhan commentedon Oct 14, 2016
@garethderioth I have no idea why. Now, I just use vim.