I have this texts
drwxr-xr-x enan enan Jan 15 16:10 Desktop/
drwxr-xr-x enan enan Jan 16 20:09 Documents/
drwxr-xr-x enan enan Jan 20 19:52 Downloads/
drwxr-xr-x enan enan Nov 3 20:44 Music/
drwxr-xr-x enan enan Jan 17 20:21 Pictures/
drwxr-xr-x enan enan Jan 20 20:10 Videos/
The spaces separating the columns are tabs. How could I replace these tabs with appropriate number of spaces so that the columns are arranged just like above, thus not altered at all.
I currently do this with :set et | '<,'> retab! | set noet
after selecting the block visually, so that '<
and '>
marks are set.
But I came across these commands which are supposed to replace tabs at the beginning of a line to spaces, but I can't understand what it's doing. I think I could change this to do the above task with one substitution, although a complicated one.
The commands:
command! -range=% -nargs=0 Tab2Space
\ execute '<line1>,<line2>s#^\t\+#\=repeat(" ", len(submatch(0))*' . &ts . ')'