Skip to content

Instantly share code, notes, and snippets.

@rdpate
Last active December 28, 2015 18:19
Show Gist options
  • Save rdpate/7541971 to your computer and use it in GitHub Desktop.
Save rdpate/7541971 to your computer and use it in GitHub Desktop.
function! DoTabify(num_spaces) range
let view = winsaveview()
execute a:firstline.','.a:lastline.'s@^ *@\=repeat("\t", len(submatch(0)) /' a:num_spaces ') . repeat(" ", len(submatch(0)) %' a:num_spaces ')'
call winrestview(view)
endfunction
command! -nargs=1 -range=% Tabify <line1>,<line2>call DoTabify(<args>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment