当前位置: 动力学知识库 > 问答 > 编程问答 >

emacs tab and spaces indentation for visual studio projects

问题描述:

At my work i have switched to using emacs from Visual Studio. Since codebase is large and my other team mates use Visual Studio (VS), i can not remove the tabs.

For myself i did this :

(setq-default indent-tabs-mode nil)

;; tab-width

(setq-default tab-width 1)

So everything looks good to me, but when i am putting code for review, it looks unintended for them or in other editors.

changing tab-width to 4 made things better but i have to remember to do C-q <TAB> again and again.

I start facing the problem :

The code has lines of average of length 130. Some go as far as 200. And i work on multiple buffers like 4 at a time. This makes code hard to read.

I then let the emacs default take charge and remove both indent-tabs-mode nil and tab-width line and i found that it was much better. It was automatically inserting tab and everything for me.

However, i had little bad experience at some places which are looking good in VS.

Also i had put these configurations from default-basics github repo. Contrastingly, there is another article on spaces are evil. Internet is full of one or another and i am confused.

What is the general guidelines that i can follow ?

SO i see Tab as 1 space it would be great. But in file they should go as "they should be".

网友答案:

Looking at the documentation of

tab-width 

Documentation:
Distance between tab stops (for display of tab characters), in columns.
This should be an integer greater than zero.

and

indent-tabs-mode

Documentation: Indentation can insert tabs if this is non-nil.

I removed the (setq-default indent-tabs-mode nil) and set the (set tab-width 1)

so now emacs handles the indentation and i see the tabs as 1 column width.

分享给朋友:
您可能感兴趣的文章:
随机阅读: