Vim Convert Tabs To Spaces
Viewed 26k times 15.
Vim convert tabs to spaces. And add the following lines to your vimrc file. Command then all the tabs becomes spaces. 1 s t g note that in both of these examples the g character at the end of the command means global.
Replace the size of the tabstop and shiftwidth as you see neccesary. Each command accepts an argument that specifies the number of spaces in a tab column. By default the tabstop setting is used.
Return indent all whitespace at start of a line converted from tabs to spaces if what 1 or from spaces to tabs otherwise. However with some configuration vim makes working with spaces for indentation as easy as working with tabs. From the first line to the last line 1 swap each tab t with two spaces i e convert each tab to two spaces do this globally g on each line meaning that if there is more than one tab on any line make sure you convert all of them.
It s in posix so it should be available on most systems. So first set the number of spaces a tab should be then set expandtab. Set tabstop 2 shiftwidth 2 expandtab.
To convert each tab in the file to two spaces i used this command. Ask question asked 9 years 4 months ago. This file will be parsed for configuration parameters when you open vim.
To edit this file or create it if it doesn t exist open a terminal and type vim vimrc. If you want to do this for selected text then first select the text in visual mode. For example to convert only the current line to use spaces use retab.