I am starting on a project where everyone is using Microsoft Visual Studio to edit code. But I am an Emacs user.
When I open those C++ files in my Emacs they look bizarre. Example:
namespace·ns·{
»class·Foo·{
»»virtual·function_name(·some_type::const_iterator·start
»»»»»»»»····,·some_type::const_iterator·end
»»»»»»»»»,·boost::shared_ptr<some_type>·varname·)·=·0;
»};
}
where I here display a tab as »
, and a space as '.', to show the differences.
I'd like to view and edit code transparently, so that it looks right in my Emacs and is saved so that it looks normal to the Visual Studio users.
So, how can I set Emacs so that it shows the files like they were supposed to be shown, which is presumably:
namespace ns {
class Foo {
virtual function_name( some_type::const_iterator start
, some_type::const_iterator end
, boost::shared_ptr<some_type> varname ) = 0;
};
}
And I'd like to tell Emacs to save it using the tabs in the original, weird, way.
Setting tab-width 3 gives us:
namespace ns {
class Foo {
virtual function_name( some_type::const_iterator start
, some_type::const_iterator end
, boost::shared_ptr<some_type> varname ) = 0;
};
}
which is as close to your presumed formatting as we can get, but not exact. Do you know if that matches what Visual Studio shows?
You'll presumably want the following:
(add-hook 'c++-mode-hook 'my-c++-mode-hook)
(defun my-c++-mode-hook ()
(setq tab-width 3
indent-tabs-mode t
c-basic-offset 3))
Hopefully that makes a good start, but there are bound to be other settings needed to match how Visual Studio does things, so I would suggest you start reading at the Emacs Wiki:
http://www.emacswiki.org/emacs/IndentingC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With