1

I have created a patch using git format-patch command and passing it to checkpatch.pl script which results in lots of code indent should never use tabs error.

But I'm not sure it should be fixed it ?

I'm using vi as an editor in unix environment .

Please advise me on how should I fix it?

Amit Singh Tomar
  • 8,380
  • 27
  • 120
  • 199
  • It's a little ambiguous what part/output you're trying to edit, but you can replace all tab characters with spaces using `:%s/\t/ /` (4 spaces). – timss Nov 27 '14 at 15:24
  • possible duplicate of [Redefine tab as 4 spaces](http://stackoverflow.com/questions/1878974/redefine-tab-as-4-spaces) – Aaron Digulla Nov 27 '14 at 15:31
  • Thanks @timss but still see same error "code indent should never use tabs" – Amit Singh Tomar Nov 27 '14 at 17:32
  • Oh right, sorry, I forgot that I had `set gdefault` in my config which always does `s//g`, i.e. all matches in a line is substituted instead of just one. Can you try with `:%s/\t/ /g`? – timss Nov 27 '14 at 18:26
  • I just tried but I'm seeing Pattern not found: \t . – Amit Singh Tomar Nov 27 '14 at 19:13
  • @AmitSinghTomar In that case it doesn't sound like your file includes any tabs. Again it's hard to understand where you're actually changing your text, but are you sure you're trying to edit the correct text? Do you find anything with a simple `/\t` search? – timss Nov 28 '14 at 13:06

1 Answers1

1

The setting that controls whether <Tab> and autoindent insert tabs or spaces is

" spaces
set expandtabs

" tabs
set noexpandtabs

This works in conjunction with tabstop, softtabstop and shiftwidth settings (you most likely want to keep these equal):

set tabstop=4 softtabstop=4 shiftwidth=4

You can also abbreviate all of these:

set et ts=4 sts=4 sw=4

Once your options are set, you can convert the current file's unwanted tabs to spaces (or unwanted spaces to tabs, if noexpandtabs) by issuing the :retab command.

Using a modeline in each file (:help modeline) or a project editorconfig with the editorconfig editor plugin are advisable to avoid this situation in the future when sharing code with individuals with unknown editor defaults.

Amadan
  • 191,408
  • 23
  • 240
  • 301