Version 2 (modified by 13 years ago) (diff) | ,
---|
Editor Configuration Snippets
Emacs
Suppose your personal preferred indentation style is dissimilar from the Pidgin indentation style, but you're a team player and you want to use Pidgin indentation when working on Pidgin/libpurple/whatever. These snippets can help you with that.
(c-add-style "pidgin" '((c-tab-always-indent . t) (c-basic-offset . 8) (indent-tabs-mode . t))) (defun pidgin-c-mode-init () (if (or (posix-string-match "some/path/snippet" (buffer-file-name)) (posix-string-match "code/pidgin" (buffer-file-name))) (c-set-style "pidgin"))) (add-hook 'c-mode-hook 'pidgin-c-mode-init)
Make sure this hook runs after your normal setup hook, if your normal hook sets a style. The or is included just to show how to match multiple paths. You may perform the selection however you like, path snippets just happen to be useful given my filesystem organization. -- elb
VIM
Regardless of what the indentation style and tab width convention is in the rest of the tree, the ChangeLog and NEWS files should always use a tab width of 8. This may not be the right or best .vimrc snippet to do this, but it works. Insert this snippet into .vimrc (.gvimrc for you GUI addicts) after your existing tab configuration:
autocmd! BufReadPost,BufNewFile */ChangeLog call <SID>ChangeLogNewsOptions() autocmd! BufReadPost,BufNewFile */NEWS call <SID>ChangeLogNewsOptions() function! <SID>ChangeLogNewsOptions() " These settings affect ChangeLog and NEWS files only setlocal sw=8 setlocal tabstop=8 endfunction