Skip to content

Instantly share code, notes, and snippets.

@ericdouglas
Last active February 25, 2024 10:09
Show Gist options
  • Star 83 You must be signed in to star a gist
  • Fork 15 You must be signed in to fork a gist
  • Save ericdouglas/72621cb47b368297feaa to your computer and use it in GitHub Desktop.
Save ericdouglas/72621cb47b368297feaa to your computer and use it in GitHub Desktop.
Change 4 spaces to 2 spaces indentation and change tab to spaces - Vim tip
// 4 spaces to 2 spaces
%s;^\(\s\+\);\=repeat(' ', len(submatch(0))/2);g
// Tab to 2 spaces
:%s/\t/ /g
@sadovnik
Copy link

Thank you!

@ryaninhust
Copy link

Thanks a lot.

@rajesh-battala
Copy link

Thanks for the tip

@amcolash
Copy link

amcolash commented Mar 3, 2017

Perfect, thanks!

@benwoodward
Copy link

Thanks!

@halilim
Copy link

halilim commented Jan 9, 2020

I couldn't get various incarnations of :retab or = to work properly, but this one did it!

@krehwell
Copy link

hey there, I made an improvement to allow this method to be used in a selected code only by making a function for it. source - gist

@Ulv3r
Copy link

Ulv3r commented Dec 17, 2021

Thanks!

@fakeowl1
Copy link

fakeowl1 commented Mar 9, 2023

Thank you!

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