unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to indent C/C++ as VI.
@ 2005-06-06  9:12 Raymond
  2005-06-07  7:05 ` Dhruva Krishnamurthy
  0 siblings, 1 reply; 2+ messages in thread
From: Raymond @ 2005-06-06  9:12 UTC (permalink / raw)


Hi everyone.

In cc-mode, Emacs can indent the C/C++ code by several modes, Such as 
bsd,cc-mode, gnu,stroustrup, whitesmith.

But in my lab. The code was written by VI. And all C/C++ code is 
indented by TAB. Just like this:

#include <iostream>

int main(int argc, char* argv[])
{
<TAB>std::cout << "Hello world!"
<TAB><TAB><<std::endl;
<TAB>return 0;
}

Are there any indent mode compatible with this mode.
Thank you very much.
Raymond

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to indent C/C++ as VI.
  2005-06-06  9:12 How to indent C/C++ as VI Raymond
@ 2005-06-07  7:05 ` Dhruva Krishnamurthy
  0 siblings, 0 replies; 2+ messages in thread
From: Dhruva Krishnamurthy @ 2005-06-07  7:05 UTC (permalink / raw)


>>>>> On Mon, 06 Jun 2005 17:12:58 +0800, Raymond <rshen_bea@yahoo.com> said:

ra> But in my lab. The code was written by VI. And all C/C++ code is indented
ra> by TAB. Just like this:

ra> int main(int argc, char* argv[]) { <TAB>std::cout << "Hello world!"
ra> <TAB><TAB><<std::endl; <TAB>return 0;
ra> }

I use the following settings (without TABS), I have modified to use TABS. Give
it a try, this might just work for you too.

;;------------------------ START [put this in .emacs] -------------------------
;;-----------------------------------------------------------------------------
;; Local C/C++ style
;;-----------------------------------------------------------------------------
;; insert HARD tabs on indentation
(setq indent-tabs-mode t)
(defconst dky-style
  '((tab-width                          . 4)
    (c-basic-offset                     . 4)
    (c-tab-always-indent                . t)
    (c-comment-only-line-offset         . 0)
    (c-hanging-braces-alist             . ((substatement-open after)
                                           (brace-list-open)))
    (c-hanging-colons-alist             . ((member-init-intro before)
                                           (inher-intro)
                                           (case-label after)
                                           (label after)
                                           (access-label after)))
    (c-cleanup-list                             . (scope-operator
                                                   empty-defun-braces
                                                   defun-close-semi))
    (c-offsets-alist                    . ((arglist-close . c-lineup-arglist)
                                           (substatement-open . 0)
                                           (case-label            . +)
                                           (block-open            . 0)
                                           (inline-open           . 0)
                                           (inline-close          . 0)
                                           (knr-argdecl-intro . -)
                                           (member-init-intro . +)
                                           (access-label          . -1000)
                                           (statement-block-intro . +)))
    (indent-tabs-mode                   . nil)
    (c-echo-syntactic-information-p     . nil)
    (comment-style                      . multi-line))
  "*User defined C/C++ Programming Style")
(c-add-style "dky" dky-style t)
(setq c-default-style "dky")
;;------------------------ END -------------------------


-dk

-- 
Name : Dhruva Krishnamurthy (dk)
Phone: +91-(0)80-22999190
Proud FSF member: #1935

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-06-07  7:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-06  9:12 How to indent C/C++ as VI Raymond
2005-06-07  7:05 ` Dhruva Krishnamurthy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).