3 ms·
For programming in languages where indentation means a nested block: >> and << indent the current line right and left by one indent position respectively, t
by fuzztester 3y ago
For programming in languages where indentation means a nested block:
>>
and
<<
indent the current line right and left by one indent position respectively, typically a tab or 4 spaces, though I need to check whether it works for spaces.
Prefixing those with a number n will indent n lines, starting with the current one.
- tremon 3y agoThis works in all filetypes, and the indentation amount is set by shiftwidth. Whether tabs or spaces are inserted is controlled by expandtab (for spaces) or noexpandtab (use tabs). You can use any navigation command as the target, I find myself often using >} to indent every line until the end of the block.
- cerved 3y agoor >ap
- fuzztester 3y ago>You can use any navigation command as the target, I find myself often using > >} >to indent every line until the end of the block. Yes, that's a good one for code in languages where } marks the end of a block, such as C, C++, Java, etc. I also use >G to indent from current line to end of file in a text file, or 1G>G which is 1G to go to line 1, and then >G to indent to end of file, which indents the whole file, which can be useful for printing on paper, more so when combined with other options like shiftwidth, !fmt, etc. (also mentioned in this thread). And many other such combinations of the indent operation and some movement, for structuring text or code, are possible. All such combinations are based on the same principles mentioned in the Stack Overflow "grok vi" comment that I posted about in this thread: https://news.ycombinator.com/item?id=37018215 https://news.ycombinator.com/item?id=37018215