You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The claim made on the website, that "indenting multiple lines" is a missing feature for vim is actually untrue, even for the old vi:
You correctly say that > is indent and < is unindent.
Now those operators can be combined with a motion, for example the infamous h, j, k or l for left, up, down or right respectively, which means that "indenting the next three lines" becomes:
v3j>
Which translates to :
v "visual mode" (select stuff)
3 "repeat" the next thing "3 times"
j "move one line down" (which is being repeated 3 times)
> "indent"
So the whole translated "sentence" (it is a very reasonable way to think of those "chains" of commands as sentences, you can even construct a complete formal language for them) would be this:
visually select 3 lines down, indent that
Another example would be to indent everything inside a certain block delimited by a curly bracket (for example useful in programming), or indent one paragraph. That would look like this:
vi}>
Which translates to
v again, "visual mode" (select something)
i "inside" (this is a modifier for addressing a text object. A bit more on that in the next bullet point.)
} the delimiter for the "inside" from before. This means, that the text object we want to interact with is everything inside the nearest curly brackets.
> "indent" again
visually select everything inside the nearest curly brackets, indent that
This is actually the biggest difference in design philosophy of vi/vim and virtually every other editor, and also what makes it such a great tool for increasing productivity: You can quite literally speak with vim in some sort of "sentences" to tell it what to do. Combined with the extensibility of newer versions, this creates virtually endless options to chain these commands together.
The text was updated successfully, but these errors were encountered:
I just hacked this explanation together without having time to think about how to condense it into a "user friendly" and easy to understand cheatsheet format, but if you want me to, I can try to do just that some time in the future. Not sure when I'll have time tho.
Thanks! I wasn't too clear about the indenting problem, so I made some edits. What I meant was repeatedly indenting/unindenting. In an interactive way. Something that typical IDEs make really easy. You can use things like gv to reselect, or . to repeat, but these are just cumbersome. My .vimrc has a way to re-select after an indent operation happens, to make it more intuitive.
The claim made on the website, that "indenting multiple lines" is a missing feature for vim is actually untrue, even for the old vi:
You correctly say that
>
is indent and<
is unindent.Now those operators can be combined with a motion, for example the infamous
h
,j
,k
orl
for left, up, down or right respectively, which means that "indenting the next three lines" becomes:Which translates to :
v
"visual mode" (select stuff)3
"repeat" the next thing "3 times"j
"move one line down" (which is being repeated 3 times)>
"indent"So the whole translated "sentence" (it is a very reasonable way to think of those "chains" of commands as sentences, you can even construct a complete formal language for them) would be this:
Another example would be to indent everything inside a certain block delimited by a curly bracket (for example useful in programming), or indent one paragraph. That would look like this:
Which translates to
v
again, "visual mode" (select something)i
"inside" (this is a modifier for addressing a text object. A bit more on that in the next bullet point.)}
the delimiter for the "inside" from before. This means, that the text object we want to interact with is everything inside the nearest curly brackets.>
"indent" againThis is actually the biggest difference in design philosophy of vi/vim and virtually every other editor, and also what makes it such a great tool for increasing productivity: You can quite literally speak with vim in some sort of "sentences" to tell it what to do. Combined with the extensibility of newer versions, this creates virtually endless options to chain these commands together.
The text was updated successfully, but these errors were encountered: