2017-04-28 6 views
1

와 파일에 내장 스타일을 적용 : 나는 "리눅스"형식에 따라 파일에 모든 브래킷을 변경하려면나는 이렇게 작성된 C 파일했습니다 이맥스

int main(void){ 

} 

합니다.

int main(void) 
{ 

} 

어떻게하면 이멕스에서이 작업을 수행 할 수 있습니까?

편집 1 :

이 내 이맥스 파일입니다

(custom-set-variables 
;; custom-set-variables was added by Custom. 
;; If you edit it by hand, you could mess it up, so be careful. 
;; Your init file should contain only one such instance. 
;; If there is more than one, they won't work right. 
'(ansi-color-faces-vector 
    [default default default italic underline success warning error]) 
'(custom-enabled-themes (quote (tango-dark))) 
'(inhibit-startup-screen t) 
'(package-archives 
    (quote 
    (("melpa" . "https://melpa.org/packages/") 
    ("gnu" . "http://elpa.gnu.org/packages/"))))) 
(custom-set-faces 
;; custom-set-faces was added by Custom. 
;; If you edit it by hand, you could mess it up, so be careful. 
;; Your init file should contain only one such instance. 
;; If there is more than one, they won't work right. 
) 

(setq make-backup-files nil) ; stop creating backup~ files 
(setq auto-save-default nil) ; stop creating #autosave# files 
(setq c-default-style "linux" 
     c-basic-offset 4) 

편집 2 : GNU 들여 쓰기를 호출하는 이맥스 매크로를 작성하여 해결

.

+0

[가능한 모든 이맥스 C 스타일을 적용하여 모든 소스 파일을 다시 포맷 할 수 있습니까?] (http://stackoverflow.com/questions/717177/how-can-i-apply- a-new-emacs-c-style-to-reformat-all-my-source-files) –

답변

0

기본 수행 방법은 emacs wiki page입니다. 이맥스에서 linux 스타일을 사용하려면 다음 이맥스에 대해 정의 XDG 경로가있는 경우

(setq c-default-style "linux") 

이 ~/이맥스에 위의 라인을 넣어 또는 ~ /의 .config/이맥스/설정. 당신은 버퍼와 reindent의 내용을 선택 단순히 리눅스는 C-기본 스타일을 설정 한 후, 그래서 임의의 영역을 reindent합니다 \

Ctrl 키M. 이것에 대한 자세한 내용은 CC-Mode manual

+0

그러나이 파일은 새 파일을 쓸 때만 적용됩니다. –

+0

Ctrl-M- \을 사용하면 들여 쓰기 만 수정되지만 브래킷 위치 –