Created
April 2, 2019 02:55
-
-
Save 3N4N/dcb97927119626d5d93c0c4f029fd8d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
com! -bar -range=% RemoveTabs call s:remove_tabs(<line1>,<line2>) | |
fu! s:remove_tabs(line1, line2) abort | |
let view = winsaveview() | |
let mods = 'sil keepj keepp' | |
let range = a:line1 . ',' . a:line2 | |
let pat = '\%(^\s*\)\@!\&\(.\)\t' | |
let l:Rep = {-> submatch(1) . repeat(' ', strdisplaywidth("\t", col('.') == 1 ? 0 : virtcol('.') ))} | |
let g = 0 | |
while search("\t", 'n') && g < 999 | |
exe mods . ' ' . range .'s/' . pat . '/\=l:Rep()/ge' | |
let g += 1 | |
endwhile | |
call winrestview(view) | |
endfu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment