Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There'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.



Actually, 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...


Activate 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! :)




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: