Given something like:
dadscasd
cas
casdc
How, in vim, can I alight all lines to left side?
dadscasd
cas
casdc
I installed vim tabular. I know how to align a pattern but have no idea about how to align everything to left. Also not sure vim tabular is the right tool for the job.
To do this easily without any plugins
In normal mode, press:
ggVG<<
and then press .
as many times as you need to.
An explanation of the commands
gg
: jump to the top of the fileV
: start a visual selection that grabs entire lines at a timeG
: go to the end of the file (in this case, selecting everything from start to end)<<
: move selected text left by one indentation.
: repeat last command (in this case, the one that says we should indent everything in the file one left)If you don't want to do all the lines, you only need to select the lines you want to move, using v
or V
. Then press <<
or >>
to start indenting. Once again, .
will repeat the last command issued to make your life easier.
To learn more, open vim and without typing anything else, type :h <<
and hit enter.
A faster way, without visual confirmation, is to type
:%left
where %
in this case means the whole range of the current buffer, as it is an alias for 1, $
.
see :h left
and :h range