Tuesday, July 10, 2018

Replacing With Spaces for Tabs in VI/VIM

$\mathtt{REFERENCE}$ @ Stackover

Requirement

Recently I have been doing my programming in VIM. My IDE is customized to use 2 Space Characters for a Tab. This was not the case in the VIM. I wanted the same behavior in VIM as well.

Solution

Luckily there is a very simple solution.
:set tabstop=2 shiftwidth=2 expandtab
should do the trick.

If you already have tabs, then follow it up with a nice global RE to replace them with double spaces.

If you want to persist the behavior for all the files you work with VIM, you can place the command in the file~/.vimrc (:scriptnames to see all files loaded by VIM). Otherwise you can enter the command every time you need it.






No comments:

Post a Comment