Skip to content

Instantly share code, notes, and snippets.

@krehwell
Created February 20, 2021 21:58
Show Gist options
  • Save krehwell/16f18e186a419704238ee368d884960a to your computer and use it in GitHub Desktop.
Save krehwell/16f18e186a419704238ee368d884960a to your computer and use it in GitHub Desktop.
Function to convert 4 spaces to 2 spaces indentation to the selected code only - Vim Tip

Put this in .vimrc

fun! Four2Two() range
  '<,'>s;^\(\s\+\);\=repeat(' ', len(submatch(0))/2);g
  norm!gv
endfun

Select the code V and apply it by :'<,'>call Four2Two()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment