"--- Basics set nocompatible "--- Search subfolders set path+=** "--- Display all matching files on autocomplete set wildmenu "--- Nicer netrw (directory browsing) let g:netrw_banner=0 " disable annoying banner "let g:netrw_browse_split=4 " open in prior window let g:netew_altv=1 " open splits to the right "let g:netrw_liststyle=3 " tree view "let g:netrw_list_hide=netrw_gitignore#Hide() "let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+' "--- Set Linux kernel standard tabs set tabstop=8 set softtabstop=8 set shiftwidth=8 set noexpandtab "--- Splits! set splitbelow splitright nnoremap h nnoremap j nnoremap k nnoremap l noremap :vertical resize +3 noremap :vertical resize -3 noremap :resize +3 noremap :resize -3 "--- Allow hidden buffers (open files) set hidden "--- Enable syntax highlighting if available if has('syntax') let TRUE=1 let FALSE=0 syntax on set background=dark let schemeset=FALSE if has('eval') && version >= 701 let colorscheme=fnameescape('/cathedral/conf/elflord.vim') if filereadable(colorscheme) exe "source ".colorscheme let schemeset=TRUE endif endif if ! schemeset silent! colorscheme elflord endif endif "--- Duplicate line, comment original map ,n YPi#j "--- F12 replaces (pasted) spaces with tabs nnoremap :retab! "--- F10 toggles line numbers on and off "nnoremap :set invnumber nnoremap :set number! "--- F9 highlights long lines "nnoremap l nnoremap \ :if exists('w:long_line_match') \ silent! call matchdelete(w:long_line_match) \ unlet w:long_line_match \ elseif &textwidth > 0 \ let w:long_line_match = matchadd('ErrorMsg', '\%>'.&tw.'v.\+', -1) \ else \ let w:long_line_match = matchadd('ErrorMsg', '\%>76v.\+', -1) \ endif "--- Use F7 and F8 for previous and next tab if version >= 700 nnoremap :tabp nnoremap :tabn endif "--- Totally rad tab completion if version >= 700 set wildmode=longest,list,full set wildmenu endif "--- Misc options set modeline " Allow modelines in files "set mouse=a " Mouse moves which fuck up everything "set nocompatible " This fixes the problem where arrow keys do not function properly on some systems. set showmatch " Highlights matching brackets in programming languages set autoindent " If you're indented, new lines will also be indented "set backspace=2 " This makes the backspace key function like it does in other programs set backspace=indent,eol,start " This makes the backspace key function like it does in other programs set smarttab " Improves tabbing set smartcase " Case insensitive search, unless uppercase is used "set number " Enables line numbering - breaks copying set incsearch " Show matches while typing search term set hlsearch " Highlight other matches while searching set shiftround " Always indent to multiple of shiftwidth when using spaces set pastetoggle= " toggles between paste and nopaste "--- The following commands make the navigation keys work like standard editors imap gj imap gk nmap gj nmap gk "--- The following adds a sweet menu, press F4 to use it. if exists('*fnameescape') && exists('*filereadable') "if has('eval') && version >= 701 let menufile=fnameescape(expand('$VIMRUNTIME/menu.vim')) if filereadable(menufile) exe "source ".menufile set wildmenu set cpo-=< set wcm= map :emenu endif endif "--- Scroll 3 lines before hitting the bottom/top edge set scrolloff=3 "--- Retain cursor position when paging nnoremap nnoremap "--- Make %% expand to the path of the current file if version >= 600 cabbr %% expand('%:p:h') endif "--- VimInfo management " '50 Marks will be remembered for the last 50 files you " edited. " <1000 Contents of registers (up to 1000 lines each) will be " remembered. " s100 Registers with more than 100 Kbyte text are skipped. " "100 Cursor positions will be remembered for last 100 files " :50 Last 50 entries in command-line history will be saved. " no / Since '/' is not specified, the default will be used, " that is, save all of the search history, and also the " previous search and substitute patterns. " no % The buffer list will not be saved nor read back. " no h 'hlsearch' highlighting will be restored. set viminfo='50,<1000,s100,:50,"100 "--- Automatic commands for special files if has('autocmd') " Jumping to last edited position in files on open ----------------------- " n~/.vim/viminfo The name of the file to use is "~/.vim/viminfo". ",n~/.vim/viminfo " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). " DF - Also do not do this if the file resides in the $TEMP directory, " chances are it is a different file with the same name.. augroup JumpCursorOnEdit autocmd! autocmd BufReadPost * \ if expand(":p:h") !=? $TEMP | \ if line("'\"") > 1 && line("'\"") <= line("$") | \ let JumpCursorOnEdit_foo = line("'\"") | \ let b:doopenfold = 1 | \ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) | \ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 | \ let b:doopenfold = 2 | \ endif | \ exe JumpCursorOnEdit_foo | \ endif | \ endif " Need to postpone using "zv" until after reading the modelines. autocmd BufWinEnter * \ if exists("b:doopenfold") | \ exe "normal zv" | \ if(b:doopenfold > 1) | \ exe "+".1 | \ endif | \ unlet b:doopenfold | \ endif augroup END "--- Indentation augroup Indents "--- Enable actually smart indentation (remember to disable smartindent) autocmd FileType * filetype plugin indent on "--- ..but use old autoindent for .sh files (includes .bash) autocmd! FileType sh filetype plugin indent on autocmd FileType sh inoremap # X# autocmd FileType sh set smartindent augroup END "--- Cathedral Settings let cathdefault='tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab' let cathjson='tabstop=2 softtabstop=2 shiftwidth=2 expandtab' let crontab='tabstop=8 softtabstop=8 shiftwidth=8 syntax=crontab' "--- Cathedral Files augroup Cathedral autocmd! "--- /cathedral autocmd BufRead,BufNewFile /cathedral/* exe 'setl '.cathdefault autocmd BufRead,BufNewFile /cathedral/conf/crontabs/* exe 'setl '.crontab "if exists('*fnameescape') " exe 'autocmd BufRead,BufNewFile '.fnameescape(system('/cathedral/bin/config-etc -n')).'/* exe "setl '.cathdefault.'"' "endif autocmd BufRead,BufNewFile /etc/cathedral/* exe 'setl '.cathdefault "--- ~ if ($USER == "root") autocmd BufRead,BufNewFile ~/bin/* exe 'setl '.cathdefault endif autocmd BufRead,BufNewFile ~/.vimrc2 exe 'setl '.cathdefault augroup END "--- Programming " autocmd BufRead,BufNewFile Makefile* :set noexpandtab " autocmd FileType cpp,c,java,sh,pl,php,asp setl autoindent autocmd BufRead,BufNewFile *.json exe 'setl '.cathjson "--- Highlight long lines always " autocmd BufRead,BufNewFile * syntax match Search /\%<81v.\%>77v/ " autocmd BufRead,BufNewFile * syntax match ErrorMsg /\%>80v.\+/ endif "--- Run the additional vimrc file in the user's home directory, if available if exists('*fnameescape') && exists('*filereadable') let rc2=fnameescape(expand('$HOME/.vimrc2')) if filereadable(rc2) exe 'source '.rc2 endif endif