简体   繁体   中英

python file edited in vim move to intellij meet inconsistent indentation error

I am a vim user and edited a large python file using vim, everything is OK and it could run properly. Now I want to build a huge projects and I want to edit this python file in Intellij, but the indentation in intellij is completely wrong, and it's hard for me to edit one line by one line. Do you know what happened? (if the edit some lines in Intellij to remove the indentation error, when I display them in vim, they are wrong indentation as well)

Most probably the file contains tab characters. See if you can replace them with spaces uniformly. Vim can do that.

http://vim.wikia.com/wiki/Converting_tabs_to_spaces

It seems that vim used tabs for indentation whereas it is common in Python to use whitespaces. Code -> Reformat Code... in Intellij will make correct indentation. Or you can choose Edit -> Convert Indents and convert tabs to white spaces.

This is not really a solution for your specific problem but Editorconfig has plugins for many editors and IDEs. It's the perfect tool to guarantee consistant indentation across a project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM