The following command will substitute all tabs in a file with four blank spaces:
%s/\t/ /g
In order to run this command whenever I open a new file I included it in my .vimrc by adding:
autocmd BufNewFile * exec "%s/\t/ /g"
However this didn't work. Does anyone know why?
BufRead? – Rich May 24 '18 at 09:02:retabcommand. – Rich May 24 '18 at 09:04readonlyornomodifiableit will probably throw a bunch of errors, also the use ofgdefaulthas to be considered. I would not recommend this setting! Better would be to set yourtabstopsetting appropriately and have Vim display tabs as 4 spaces. – Christian Brabandt May 24 '18 at 09:50