From a019f8e837d9e641a955f928ded00be4db149957 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 29 Jun 2018 16:26:37 +1200 Subject: Set 'include' and 'path' specifically in C/C++ Otherwise, use defaults that should be meaningful in other languages too, just to be tidy and not to show string.h in :find results when editing Awk scripts. --- vim/after/ftplugin/c/include.vim | 22 ++++++++++++++++++++++ vim/after/ftplugin/cpp/include.vim | 22 ++++++++++++++++++++++ vim/vimrc | 7 +++++-- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 vim/after/ftplugin/c/include.vim create mode 100644 vim/after/ftplugin/cpp/include.vim diff --git a/vim/after/ftplugin/c/include.vim b/vim/after/ftplugin/c/include.vim new file mode 100644 index 00000000..ce78d495 --- /dev/null +++ b/vim/after/ftplugin/c/include.vim @@ -0,0 +1,22 @@ +" c/include.vim: Set 'include' and 'path' + +" Don't load if running compatible or too old +if &compatible || v:version < 700 + finish +endif + +" Don't load if already loaded +if exists('b:did_ftplugin_c_include') + finish +endif + +" Flag as loaded +let b:did_ftplugin_c_include = 1 +let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:did_ftplugin_c_include' + +" Use trailing whitespace to denote continued paragraph +setlocal include=^\\s*#\\s*include +setlocal path+=/usr/include +let b:undo_ftplugin = b:undo_ftplugin + \ . '|setlocal include< path<' diff --git a/vim/after/ftplugin/cpp/include.vim b/vim/after/ftplugin/cpp/include.vim new file mode 100644 index 00000000..6c039287 --- /dev/null +++ b/vim/after/ftplugin/cpp/include.vim @@ -0,0 +1,22 @@ +" c/include.vim: Set 'include' and 'path' + +" Don't load if running compatible or too old +if &compatible || v:version < 700 + finish +endif + +" Don't load if already loaded +if exists('b:did_ftplugin_cpp_include') + finish +endif + +" Flag as loaded +let b:did_ftplugin_cpp_include = 1 +let b:undo_ftplugin = b:undo_ftplugin + \ . '|unlet b:did_ftplugin_cpp_include' + +" Use trailing whitespace to denote continued paragraph +setlocal include=^\\s*#\\s*include +setlocal path+=/usr/include +let b:undo_ftplugin = b:undo_ftplugin + \ . '|setlocal include< path<' diff --git a/vim/vimrc b/vim/vimrc index f48f31b6..73f6b48b 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -74,6 +74,9 @@ if v:version > 703 || v:version == 703 && has('patch541') set formatoptions+=j endif +" Don't assume I'm editing C; let the filetype set this +set include= + " Don't join lines with two spaces at the end of sentences set nojoinspaces @@ -124,9 +127,9 @@ if has('extra_search') set incsearch " Show matches as I type endif -" Use whole tree from current directory for :find +" More sensible language-agnostic setting for gf/:find if has('file_in_path') - set path+=** + set path=.,,** endif " Don't load GUI menus; set here before GUI starts -- cgit v1.2.3