Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expand Tabs in VIM

Tags:

vim

I have a file with a lot of tabs that i need to set the tab spacing to 4 and expand out the tabs. I am able to set expandtab but it does not expand out the tabs for tabs already in the file.

like image 986
user294280 Avatar asked Jun 12 '11 17:06

user294280


2 Answers

Do the following

:se et
:se ts=4
:ret

The first command sets the expand tab, the second sets tab spacing to 4, and finally the third one re-tabs and converts tabs to spaces

like image 167
Sai Avatar answered Oct 03 '22 00:10

Sai


"Super retab":

:retab converts all sequences of tabstops or spaces, even those that might be in a "quoted string like this". This tip shows how to convert only the indents at the line beginnings. Any spaces or tabstops after the first non-white character are not affected.

like image 35
Aaron Thoma Avatar answered Oct 03 '22 01:10

Aaron Thoma