开发者

Getting consistent indentation in Eclipse and Emacs

I am looking to start using emacs for php development. So far I have been using eclipse.

I installed the Nxhtml mode in emacs (GNU Emacs23) for this. But I observe that when a file edited in emacs is opened in eclipse the indentation breaks. In eclipse I have the following settings,

tab policy = spaces, indentation = 4

In emacs, I have this line in my .emacs file

(setq-default c-basic-offset 4)

Now lets say I create a file using emacs with the following contents

<?php 

class HelloWorld {

    public function __construct() {
        echo 'Hello World';
    }

}

If its opened in eclipse now, it shows

<?php 

class HelloWorld {

    public function __construct() {
    echo 'Hello World';
    }

}

If its indented in eclipse now by pressing tab, then emacs shows too much indentation.

NOTE: in eclipse when ENTER is pressed to go to the new line, the code gets automatically indented just the way it happens in emacs using C-j

I am unable to figure out whether it is emacs or eclipse that causing this and what needs to be configured to solve this issu开发者_C百科e.

I work with people who mainly use eclipse. The indentation problem is the only thing thats stopping me from switching over to emacs.

Any help is appreciated.

Thanks.


For anyone who comes across this in future, the variable controlling tab indentation is indent-tabs-mode

Also, if you're trying to work out what's going on with the whitespace, you might try the whitespace-mode command (use M-x whitespace mode): it shows tabs and spaces etc. much more clearly. The command toggles if you want to turn it off again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜