"=============================================================================== " " File: customization.vimrc " " Description: suggestion for a personal configuration file ~/.vimrc " " VIM Version: 7.0+ " Author: Dr. Fritz Mehner (fgm), mehner.fritz@fh-swf.de " Organization: FH Südwestfalen, Iserlohn " Version: 1.0 " Created: 18.05.2013 21:59 " Revision: --- " License: Copyright (c) 2013, Dr. Fritz Mehner "=============================================================================== " "=============================================================================== " GENERAL SETTINGS "=============================================================================== "------------------------------------------------------------------------------- " Use Vim settings, rather then Vi settings. " This must be first, because it changes other options as a side effect. "------------------------------------------------------------------------------- set nocompatible " "------------------------------------------------------------------------------- " Enable file type detection. Use the default filetype settings. " Also load indent files, to automatically do language-dependent indenting. "------------------------------------------------------------------------------- filetype plugin on filetype indent on " "------------------------------------------------------------------------------- " Switch syntax highlighting on. "------------------------------------------------------------------------------- syntax on " " Platform specific items: " - central backup directory (has to be created) " - default dictionary " Uncomment your choice. if has("win16") || has("win32") || has("win64") || \ has("win95") || has("win32unix") " " runtime mswin.vim " set backupdir =$VIM\vimfiles\backupdir " set dictionary=$VIM\vimfiles\wordlists/german.list else " set backupdir =$HOME/.vim.backupdir " set dictionary=$HOME/.vim/wordlists/german.list endif " " Using a backupdir under UNIX/Linux: you may want to include a line similar to " find $HOME/.vim.backupdir -name "*" -type f -mtime +60 -exec rm -f {} \; " in one of your shell startup files (e.g. $HOME/.profile) " "------------------------------------------------------------------------------- " Various settings "------------------------------------------------------------------------------- set autoindent " copy indent from current line set autoread " read open files again when changed outside Vim set autowrite " write a modified buffer on each :next , ... set backspace=indent,eol,start " backspacing over everything in insert mode set backup " keep a backup file set browsedir=current " which directory to use for the file browser set complete+=k " scan the files given with the 'dictionary' option set history=50 " keep 50 lines of command line history set hlsearch " highlight the last used search pattern set incsearch " do incremental searching set listchars=tab:>.,eol:\$ " strings to use in 'list' mode set mouse=a " enable the use of the mouse set nowrap " do not wrap lines set popt=left:8pc,right:3pc " print options set ruler " show the cursor position all the time set shiftwidth=2 " number of spaces to use for each step of indent set showcmd " display incomplete commands set smartindent " smart autoindenting when starting a new line set tabstop=2 " number of spaces that a counts for set visualbell " visual bell instead of beeping set wildignore=*.bak,*.o,*.e,*~ " wildmenu: ignore these extensions set wildmenu " command-line completion in an enhanced mode " "=================================================================================== " BUFFERS, WINDOWS "=================================================================================== " "------------------------------------------------------------------------------- " The current directory is the directory of the file in the current window. "------------------------------------------------------------------------------- if has("autocmd") autocmd BufNewFile,BufRead * :lchdir %:p:h endif " "------------------------------------------------------------------------------- " close window (conflicts with the KDE setting for calling the process manager) "------------------------------------------------------------------------------- noremap :close inoremap :close " "------------------------------------------------------------------------------- " Fast switching between buffers " The current buffer will be saved before switching to the next one. " Choose :bprevious or :bnext "------------------------------------------------------------------------------- noremap :if &modifiable && !&readonly && \ &modified :write :endif:bprevious inoremap :if &modifiable && !&readonly && \ &modified :write :endif:bprevious " "------------------------------------------------------------------------------- " Leave the editor with Ctrl-q (KDE): Write all changed buffers and exit Vim "------------------------------------------------------------------------------- nnoremap :wqall " "------------------------------------------------------------------------------- " 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). "------------------------------------------------------------------------------- if has("autocmd") autocmd BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif endif " has("autocmd") " "------------------------------------------------------------------------------- " some additional hot keys "------------------------------------------------------------------------------- " F2 - write file without confirmation " F3 - call file explorer Ex " F4 - show tag under curser in the preview window (tagfile must exist!) " F5 - open quickfix error window " F6 - close quickfix error window " F7 - display previous error " F8 - display next error "------------------------------------------------------------------------------- " noremap :write noremap :Explore nnoremap :exe ":ptag ".expand("") noremap :copen noremap :cclose noremap :cp noremap :cn " inoremap :write inoremap :Explore inoremap :exe ":ptag ".expand("") inoremap :copen inoremap :cclose inoremap :cp inoremap :cn "------------------------------------------------------------------------------- " autocomplete parenthesis, brackets and braces "------------------------------------------------------------------------------- inoremap ( () inoremap [ [] inoremap { {} " vnoremap ( s()P vnoremap [ s[]P vnoremap { s{}P " "------------------------------------------------------------------------------- " autocomplete quotes "------------------------------------------------------------------------------- vnoremap ' s''P vnoremap " s""P vnoremap ` s``P " inoremap ' ':call QuoteInsertionWrapper("'")a inoremap " ":call QuoteInsertionWrapper('"')a inoremap ` `:call QuoteInsertionWrapper('`')a " "------------------------------------------------------------------------------- " function QuoteInsertionWrapper {{{3 " " Add a second quote only if the left and the right character are not keyword " characters and the right character is not the same quote. "------------------------------------------------------------------------------- function! QuoteInsertionWrapper (quote) let col = col('.') let line = getline('.') if ( line[col-2] =~ '\k' ) \ || ( line[col ] =~ '\k' ) \ || ( line[col-2] =~ a:quote ) \ || ( line[col ] =~ a:quote ) return a:quote else return a:quote.a:quote."\" endif endfunction " "=============================================================================== " VARIOUS PLUGIN CONFIGURATIONS "=============================================================================== " "------------------------------------------------------------------------------- " plugin bash-support.vim "------------------------------------------------------------------------------- " --empty -- " "------------------------------------------------------------------------------- " taglist.vim : toggle the taglist window "------------------------------------------------------------------------------- noremap :Tlist inoremap :Tlist