4 ms·
Another built-in solution to the problem of mismatches when using the jump commands (f, t, F, T) is the use of ; and , Semicolon will repeat the last jump comm
by zefhous 14y ago
Another built-in solution to the problem of mismatches when using the jump commands (f, t, F, T) is the use of ; and ,
Semicolon will repeat the last jump command, and comma will repeat it in the opposite direction.
I find this very useful not only for mismatches that I didn't see, but also for help with quickly formatting text. Along side . to repeat an action, it's incredibly fast to use ; to repeat your last jump (like to < for an html tag) and then use . to repeat the last command (like dst, to delete the surrounding html tag). This is a just one example, but it's a quick and easy pattern I use to do things like selectively stripping html tags within a string that has some inline html, or moving around quickly within arrays.
- goldfeld 14y agoOh, you reminded me to mention that ; and , integration is planned! I'll probably have to work something out with tpope's repeat plugin, or if it's simpler I'll just make a self-contained solution. I want seek to act just like a more selective f. The thing about repeating f is that if you are as little as 5 words away from your target you could be looking at 3-4 repeeats, and by then it wouldn't have been anywhere close the most efficient solution--plus it creates a habit of the read-eval-print loop, aka trial and error. Vim should allow you to always say what you want and get there. I find seek useful even in going to the beginning and end of close words, just use spacebar + char or char + spacebar.
- to3m 14y agoThe problem with ; is that it doesn't work with t. It just leaves the cursor in the same place, because that's exactly what your t command would do if you typed it again. It's now some years since I used vim regularly but I recall this regularly annoying me when trying to create visual selections. For example, I'd do "vt," (or whatever) expecting the selection to extend to a given point, and then find myself stuck at a , that I hadn't noticed. And then I'd have to move the cursor by hand to fix things, just like you would in some ordinary text editor.
- zefhous 14y agoThat's odd. With my configuration I can use ; with t and it will skip over an occurrence of the target if it is the next character, like it seems you expect it to behave. I don't know if this has been fixed/improved in Vim itself or by some plugin that I use, but it does seem to be fixed now.
- kps 14y agoIn vim, the ‘new’ behaviour (skipping the target if there would be no motion) is the default, and the original vi behaviour can be selected using cpoptions; see :help cpo-;
- danneu 14y agoI remapped `;` to `:` (try it, it's fun!) and evolved my character jump usage into just using `/` + two characters of resolution. So many times I'd do an `f` search like `fs` only to realize the variable `she_sells_sea_shells_by_the_sea_shore` appears between me and my destination. Ugh!
- gnosis 14y agoYou're missing out on using the normal meaning of ; which is really useful. I prefer to map the space bar to : instead. The space bar is not usually mapped to anything, so you wouldn't be masking any other function by mapping it. Also, for jumping long distances, you should really try PreciseJump or EasyMotion. (mentioned elsewhere in this thread)
- z92 14y agoReading your comment I have just mapped "space" to ":" ":" to "," That makes sense. Now ; and shift-: works in pair how n and shift-N works in pair.
- goldfeld 14y agoGood idea, I have just remapped mm (mmw feels natural in Dvorak) to : and my pinkies are gonna be thanking you two many times over.