User Tools

Site Tools


emacs:emacs

Emacs

Set up custom lisp path

(add-to-list 'load-path "~/.emacs.d/lisp/")

Show trailing whitespace

Show trailing whitespace as red blocks:

(custom-set-variables
 '(show-trailing-whitespace t)
)

Use Allman/BSD style

Make curly braces placement as described by Allman from the BSD project:

(setq c-default-style "bsd" c-basic-offset 4)

Use SmartTabs

Use "SmartTabs", ie. tabs for indentation and spaces for alignment.

Create the folder ~/.emacs.d/lisp and download smart-tabs-mode.el and cl-lib into it.

Add the following lines to the .emacs file:

(require 'smart-tabs-mode)
 
(autoload 'smart-tabs-mode "Intelligently indent with tabs, align with spaces!")
(autoload 'smart-tabs-mode-enable "smart-tabs-mode")
(autoload 'smart-tabs-advice "smart-tabs-mode")
(autoload 'smart-tabs-insinuate "smart-tabs-mode")
 
(smart-tabs-insinuate 'c 'c++ 'java 'javascript 'cperl 'ruby 'nxml)

Switch between cc/h files

Switch between the header and implementation using Alt-o.

Download SwitchFile.el to the ~/emacs.d/lisp folder.

(require 'switch-file)
(global-set-key (kbd "M-o") 'switch-cc-to-h)

Show whitespace

Download whitespace.el into the ~/.emacs.d/lisp folder.

Use it whenever in c++ mode:

(require 'whitespace)
(add-hook 'c++-mode-hook 'whitespace-mode)

Use sane colors:

(set-face-attribute 'whitespace-space nil :background nil :foreground "LightCyan2")
(set-face-attribute 'whitespace-space-after-tab nil :background nil :foreground "LightCyan2")
(set-face-attribute 'whitespace-tab nil :background nil :foreground "LightCyan2")
(set-face-attribute 'whitespace-line nil :foreground nil :background nil :weight 'bold)

Disable newlines and wierd rendering of long lines:

(custom-set-variables
 '(whitespace-style (quote (face tabs spaces trailing space-before-tab indentation empty space-after-tab space-mark tab-mark))
)
emacs/emacs.txt · Last modified: 2015/09/12 20:24 by deva