Single hjkl enabled, while repetitive striking disabled?
wikitopian opened this issue · 16 comments
teimu on r/vim and others have noted that these keys can be constructively integrated into intelligent motion commands, such as v5jd
to delete five lines down and so on.
Is there a graceful way to allow for j
but disallow jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
?
And should that be a separate mode or an enhancement to hard mode? I'm kind of favoring the latter?
How about something like this? Another option might be to make Vim sleep
a bit after each repetition.
I think it is definitely an enhancement. There is no reason not to use hjkl
if you need to move exactly one character, for instance when doing something like jdd
.
This should definitely be added in the regular hardmode, because navigating using the hjkl in a non repetitive way should be allowed.
I for example use relative line numbers so I can easily jump to a certain line by just looking at the line numbers and hittting j/k and actually disabled the plugin for now because it slowed me down even when not using anti-patterns
I'm honestly not sharp enough with VimScript to discern whether your proposed solution is graceful and appropriate or not, @dbakker , or what the pros and cons of this solution or alternative solutions is.
I'm a bit swamped with work this coming week, but I'll take some time to figure out what's going on in your function and whether it's the right way to go.
Anybody else have any thoughts on his HardModeHJKL
function?
The code looks fine to me (Not a vimscript expert though), only thing I'd do is namespace the variables too: g:HardMode__lastPos
(2nd underscore implying internal use only).
I agree HardModeHJKL
would be great! I was actually coming to open up the same issue lol. Perhaps even two or three quick hjkl
's would be allowed? It seems that it takes more keystrokes to move down a few lines without typing 2j
or jj
BTW, thanks a ton for this plugin @wikitopian ! I've really enjoyed using it when i'm trying to exercise my vim muscles. The first time with it enabled was almost as painful as my first hour with vim 😄
I'm currently looking at this and testing it.
Only issue so far is losing visual selection when you hit the limit of repetitive HJKL strokes.
@AdamBrodzinski I'm also looking at implementing a setting with how many HJKL's are allowed, well attempting to
Ok it's implemented including the config option, can people please test https://github.com/xeross/vim-hardmode/tree/hjkl-repeat
There also seems to be some initialization issue when calling HardMode() which goes away if you change buffers, not sure why that happens.
Found another bug, switching to insert mode and back does not reset the count.
@xeross Great!! I'll make some time tomorrow night to dig in and test it out. Kudos!
I've been using the hjkl-repeat branch for a few days and it works great (besides the bugs you've already mentioned).
This isn't a bug but a design decision I wanted to bring up: If I set my limit to 1, and hit j, then 10j, it still counts that second j as passing the limit and that second command doesn't go through. I expected the 10 to reset my limit. Of course if it did reset, this allows 1j1j1j but I don't think anyone using this plugin would do that :).
I found a bug. When you go into insert mode, exit, then try and backspace, backspace fails. It also has this behavior in other buffers that hard mode doesn't work in. I made a quick screencast of this and uploaded it to my dropbox. Unfortunately I couldn't narrate as everyone was asleep but it should be easy to follow with the keyboard clicking =)
https://dl.dropbox.com/u/1407764/github/hardmode_backspace_bug.mov
_edit_ I just read through the source and realized that the backspace is a normal behavior! However, it doesn't flash the easymode warning when you hit backspace.
Yes, single hjkl
would be great. Relative jumps like 5j
would be good to encourage even in hard mode.
Currently trying out hjkl-repeat
branch in xeross/vim-hardmode
My current code is bugged as detailed above, however I do not possess the knowledge to fix this.
You could add au InsertLeave * let g:HardMode_lastType = ''
to make HardMode reset on InsertLeave.
With xeross' patch i can do j10j
and it works fine (because of the v:count check in the code), are you sure you are using this code frankychung?
sadly all the branches mentioned here are gone. Does anyone still have the latest code for this?
Anyone still following this? :(