AD Teaching Wiki
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

FrontPage

AD Teaching Wiki:
  • attachment:vimrc.txt of ProgrammierenCplusplusSS2010/Editor

Attachment 'vimrc.txt'

Download

   1 "" No need to be compatible with vi and lose features.
   2 set nocompatible
   3 
   4 "" Set textwidth to 80, this implies word wrap.
   5 set textwidth=80
   6 
   7 "" Show line numbers.
   8 set nu
   9 
  10 "" Automatic C-style indenting.
  11 set autoindent
  12 
  13 "" When inserting TABs replace them with the appropriate number of spaces
  14 set expandtab
  15 
  16 "" But TABs are needed in Makefiles
  17 au BufNewFile,BufReadPost Makefile se noexpandtab
  18 
  19 "" Show matching braces.
  20 set showmatch
  21 
  22 "" Choose the right syntax highlightning per TAB-completion :-)
  23 "" map <F2> :source $VIM/syntax/
  24 
  25 "" Syntax highlightning, but only for color terminals.
  26 if &t_Co > 1
  27   syntax on
  28 endif
  29 
  30 "" Set update time to 1 second (default is 4 seconds), convenient vor taglist.vim.
  31 set updatetime=500
  32 
  33 "" Colours in xterm.
  34 map <F3> :se t_Co=16<C-M>:se t_AB=<C-V><ESC>[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm<C-V><C-M>:se t_AF=<C-V><ESC>[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm<C-V><C-M>
  35 
  36 "" Toggle between .h and .cpp with F4.
  37 function! ToggleBetweenHeaderAndSourceFile()
  38   let bufname = bufname("%")
  39   let ext = fnamemodify(bufname, ":e")
  40   if ext == "h"
  41     let ext = "cpp"
  42   elseif ext == "cpp"
  43     let ext = "h"
  44   else
  45     return
  46   endif
  47   let bufname_new = fnamemodify(bufname, ":r") . "." . ext
  48   let bufname_alt = bufname("#")
  49   if bufname_new == bufname_alt
  50     execute ":e#"
  51   else
  52     execute ":e " . bufname_new
  53   endif
  54 endfunction
  55 map <silent> <F4> :call ToggleBetweenHeaderAndSourceFile()<CR>
  56 
  57 "" Keep the horizontal cursor position when moving vertically.
  58 set nostartofline
  59 
  60 "" Reformat comment on current line. TODO: explain how.
  61 map <silent> hc ==I  <ESC>:.s/\/\/ */\/\//<CR>:nohlsearch<CR>j
  62 
  63 "" Make sure == also indents #ifdef etc.
  64 noremap <silent> == IX<ESC>==:.s/X//<CR>:nohlsearch<CR>
  65 
  66 "" Toggle encoding with F12.
  67 function! ToggleEncoding()
  68   if &encoding == "latin1"
  69     set encoding=utf-8
  70   elseif &encoding == "utf-8"
  71     set encoding=latin1
  72   endif
  73 endfunction
  74 map <silent> <F12> :call ToggleEncoding()<CR>
  75 
  76 "" Do not break long lines.
  77 set nowrap
  78 set listchars=eol:$,extends:>
  79 
  80 "" Next / previous error with Tab / Shift+Tab.
  81 map <silent> <Tab> :cn<CR>
  82 map <silent> <S+Tab> :cp<CR>
  83 map <silent> <BS><Tab> :cp<CR>
  84 
  85 "" Umlaut mappings for US keyboard.
  86 imap "a ä
  87 imap "o ö
  88 imap "u ü
  89 imap "s ß
  90 imap "A Ä
  91 imap "O Ö
  92 imap "U Ü
  93 
  94 "" After this many msecs do not imap.
  95 set timeoutlen=500
  96 
  97 "" Always show the name of the file being edited.
  98 "" set ls=2
  99 
 100 "" Show the mode (insert,replace,etc.)
 101 set showmode
 102  
 103 "" No blinking cursor please.
 104 set gcr=a:blinkon0
 105 
 106 "" Cycle through completions with TAB (and SHIFT-TAB cycles backwards).
 107 function! InsertTabWrapper(direction) 
 108     let col = col('.') - 1 
 109     if !col || getline('.')[col - 1] !~ '\k' 
 110         return "\<tab>" 
 111     elseif "backward" == a:direction 
 112         return "\<c-p>" 
 113     else 
 114         return "\<c-n>" 
 115     endif 
 116 endfunction 
 117 inoremap <tab> <c-r>=InsertTabWrapper ("forward")<cr>
 118 inoremap <s-tab> <c-r>=InsertTabWrapper ("backward")<cr>
 119 
 120 "" Cycling through Windows quicker.
 121 map <C-M> <C-W>j<C-W>_ 
 122 map <C-K> <C-W>k<C-W>_ 
 123 map <A-Down>  <C-W><Down><C-W>_
 124 map <A-Up>    <C-W><Up><C-W>_
 125 map <A-Left>  <C-W><Left><C-W>|
 126 map <A-Right> <C-W><Right><C-W>|
 127 
 128 "" Do not show any line of minimized windows
 129 set wmh=0
 130 
 131 "" Make it easy to update/reload _vimrc.
 132 :nmap ,s :source $HOME/.vimrc 
 133 :nmap ,v :sp $HOME/.vimrc 
 134 
 135 "" Latex Suite 1.5 wants it
 136 "" REQUIRED. This makes vim invoke latex-suite when you open a tex file.
 137 filetype plugin on
 138 
 139 "" IMPORTANT: win32 users will need to have 'shellslash' set so that latex
 140 "" can be called correctly.
 141 set shellslash
 142 
 143 "" IMPORTANT: grep will sometimes skip displaying the file name if you
 144 "" search in a singe file. This will confuse latex-suite. Set your grep
 145 "" program to alway generate a file-name.
 146 set grepprg=grep\ -nH\ $*
 147 
 148 "" OPTIONAL: This enables automatic indentation as you type (by 2 spaces)
 149 filetype indent on
 150 set sw=2
 151 
 152 "" no placeholders please
 153 let g:Imap_UsePlaceHolders = 0
 154 
 155 "" no " conversion please
 156 let g:Tex_SmartKeyQuote = 0
 157 
 158 "" don't use Makefile if one is there
 159 let g:Tex_UseMakefile = 0
 160 
 161 "" Syntax Highlighting for MhonArc Config files
 162 au BufNewFile,BufRead *.mrc so $HOME/.vim/mhonarc.vim
 163 
 164 "" set guifont=Courier10_BT/Roman/10
 165 set gfn=Courier\ 10\ Pitch\ 10
 166 set gfw=
 167 set go=agimrLtT

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2010-04-28 13:42:40, 4.1 KB) [[attachment:.vimrc]]
  • [get | view] (2010-04-28 13:55:08, 4.1 KB) [[attachment:vimrc.txt]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.

  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01