Is there a text editor that will automatically determine whether to indent with spaces or tabs?

It is very simple to configure the text editor to use spaces or tabs each time you press the tab key. However, I work with a grasp of Python code supported by a large development team in my company, as well as some spaces and some tabs. I can't just make them all fit together, because 1) he would break git guilt, 2) he would get confused with git diff, and 3) he would inevitably break the assembly the next time another editor gets into their tab key in one of the files.

Instead, I would like the text editor to automatically detect if the file is formatted with spaces or tabs, and then match the existing layout. Does anyone know if something like this exists?

+3
source share
6 answers

Sublime Text does this.

+5
source

I think geany ( http://www.geany.org/ ) has this option in the settings if you are using linux.

+1
source
+1

TextMate Mac .

, vim emacs.

0

vim. codeblog , :

function Kees_settabs()
    if len(filter(getbufline(winbufnr(0), 1, "$"), 'v:val =~ "^\\t"')) > len(filter(getbufline(winbufnr(0), 1, "$"), 'v:val =~ "^ "'))
        set noet ts=8 sw=8
    endif
endfunction
autocmd BufReadPost * call Kees_settabs()

- .

0

vim , . vim .

vim Python: http://henry.precheur.org/2008/4/18/Indenting_Python_with_VIM.html

EDIT: , , . vim:

filetype on
autocmd FileType python set smarttab expandtab
0

Source: https://habr.com/ru/post/1722374/


All Articles