3 ms·
I'm curious if the speed difference between counting how many times to repeat a command versus using movement/visual block/etc. is big enough? I find the "repe
by yesimahuman 15y ago
I'm curious if the speed difference between counting how many times to repeat a command versus using movement/visual block/etc. is big enough?
I find the "repeat-n-times" modifiers require a lot of thought before I know what number to put before the command. I do consider myself very fast with Vim, but the repeat commands haven't done much for me.
- Symmetry 15y agoLikewise. I very, very seldom find myself using repetitions. I mostly use simple commands or text objects, and when those don't cover some weird case I fall back to visual mode. Occasionally I know I want to delete just 2 words and so use d2w or something, but that's so rare I really notice when it happens.
- robertskmiles 15y agoThere's a great deal of power in '.', which repeats the last command. So if you have to do something 12 times, your steps could look something like this; - Run the command once - Think "Hmm, looks like I have to do this about ten more times" - Type '10.', repeating the last command 10 times - See that there's only one left to do, since you guessed 10 and it was 11 - Press '.' one more time to do the last one You won't win any vim golf competitions like that, but it's very easy to do.
- Amnon 15y agoActually, 10. doesn't necessarily repeat the last command 10 times, it just runs it again with an argument of 10. For example ">>10." will indent the current line and then indent it and the following 9 lines. I still haven't found an easy way to indent a line N times without pressing ">" 2N times...
- ddfisher 15y agoActivate visual mode first. In visual mode, the argument is used for the number of indents (because the lines to indent are selected visually). So to indent the current line 4 times, type: "V4>". Happy vimming! :)
- Derbasti 15y agoWhat I do regularly is to record a macro that combines some action with a movement. For example, I have some file with many many lines that need to be changed in a very similar fashion. (Recent example: ten comma separated numbers per line, all wrong by a factor of ten, 100 lines of those). I will record that macro, then repeat it 100 times. Since every command includes a movement at the end (say, a "j"), this will change 100 lines (or words, or regex finds, or whatever). Damn, I instinctively hit <ESC> after writing that last line.