flipje

vimrc

Jan 17th, 2012
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.32 KB | None | 0 0
  1. "{{{Auto Commands
  2.  
  3. " Automatically cd into the directory that the file is in
  4. autocmd BufEnter * execute "chdir ".escape(expand("%:p:h"), ' ')
  5.  
  6. " Remove any trailing whitespace that is in the file
  7. autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif
  8.  
  9. " Restore cursor position to where it was before
  10. augroup JumpCursorOnEdit
  11.    au!
  12.    autocmd BufReadPost *
  13.             \ if expand("<afile>:p:h") !=? $TEMP |
  14.             \   if line("'\"") > 1 && line("'\"") <= line("$") |
  15.             \     let JumpCursorOnEdit_foo = line("'\"") |
  16.             \     let b:doopenfold = 1 |
  17.             \     if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) |
  18.             \        let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 |
  19.             \        let b:doopenfold = 2 |
  20.             \     endif |
  21.             \     exe JumpCursorOnEdit_foo |
  22.             \   endif |
  23.             \ endif
  24.    " Need to postpone using "zv" until after reading the modelines.
  25.   autocmd BufWinEnter *
  26.            \ if exists("b:doopenfold") |
  27.            \   exe "normal zv" |
  28.            \   if(b:doopenfold > 1) |
  29.            \       exe  "+".1 |
  30.            \   endif |
  31.            \   unlet b:doopenfold |
  32.            \ endif
  33. augroup END
  34.  
  35. "}}}
  36.  
  37. "{{{Misc Settings
  38.  
  39. " Necesary  for lots of cool vim things
  40. set nocompatible
  41.  
  42. " This shows what you are typing as a command.  I love this!
  43. set showcmd
  44.  
  45. " Folding Stuffs
  46. set foldmethod=marker
  47.  
  48. " Needed for Syntax Highlighting and stuff
  49. filetype on
  50. filetype plugin on
  51. syntax enable
  52. set grepprg=grep\ -nH\ $*
  53.  
  54. " Who doesn't like autoindent?
  55. set autoindent
  56.  
  57. " Spaces are better than a tab character
  58. set expandtab
  59. set smarttab
  60.  
  61. " Who wants an 8 character tab?  Not me!
  62. set shiftwidth=3
  63. set softtabstop=3
  64.  
  65. " Use english for spellchecking, but don't spellcheck by default
  66. if version >= 700
  67.    set spl=en spell
  68.    set nospell
  69. endif
  70.  
  71. " Real men use gcc
  72. "compiler gcc
  73.  
  74. " Cool tab completion stuff
  75. set wildmenu
  76. set wildmode=list:longest,full
  77.  
  78. " Enable mouse support in console
  79. set mouse=a
  80.  
  81. " Got backspace?
  82. set backspace=2
  83.  
  84. " Line Numbers PWN!
  85. set number
  86.  
  87. " Ignoring case is a fun trick
  88. set ignorecase
  89.  
  90. " And so is Artificial Intellegence!
  91. set smartcase
  92.  
  93. " This is totally awesome - remap jj to escape in insert mode.  You'll never type jj anyway, so it's great!
  94. inoremap jj <Esc>
  95.  
  96. nnoremap JJJJ <Nop>
  97.  
  98. " Incremental searching is sexy
  99. set incsearch
  100.  
  101. " Highlight things that we find with the search
  102. set hlsearch
  103.  
  104. " Since I use linux, I want this
  105. let g:clipbrdDefaultReg = '+'
  106.  
  107. " When I close a tab, remove the buffer
  108. set nohidden
  109.  
  110. " Set off the other paren
  111. highlight MatchParen ctermbg=4
  112. " }}}
  113.  
  114. "{{{Look and Feel
  115.  
  116.  
  117. "Status line gnarliness
  118. set laststatus=2
  119. set statusline=%F%m%r%h%w\ (%{&ff}){%Y}\ [%l,%v][%p%%]
  120.  
  121. " }}}
  122.  
  123. "{{{ Functions
  124.  
  125. "{{{ Open URL in browser
  126.  
  127. function! Browser ()
  128.    let line = getline (".")
  129.    let line = matchstr (line, "http[^   ]*")
  130.    exec "!konqueror ".line
  131. endfunction
  132.  
  133. "}}}
  134.  
  135. "{{{Theme Rotating
  136. let themeindex=0
  137. function! RotateColorTheme()
  138.    let y = -1
  139.    while y == -1
  140.       let colorstring = "inkpot#ron#blue#elflord#evening#koehler#murphy#pablo#desert#torte#"
  141.       let x = match( colorstring, "#", g:themeindex )
  142.       let y = match( colorstring, "#", x + 1 )
  143.       let g:themeindex = x + 1
  144.       if y == -1
  145.          let g:themeindex = 0
  146.       else
  147.          let themestring = strpart(colorstring, x + 1, y - x - 1)
  148.          return ":colorscheme ".themestring
  149.       endif
  150.    endwhile
  151. endfunction
  152. " }}}
  153.  
  154. "{{{ Paste Toggle
  155. let paste_mode = 0 " 0 = normal, 1 = paste
  156.  
  157. func! Paste_on_off()
  158.   if g:paste_mode == 0
  159.      set paste
  160.      let g:paste_mode = 1
  161.   else
  162.      set nopaste
  163.      let g:paste_mode = 0
  164.   endif
  165.   return
  166. endfunc
  167. "}}}
  168.  
  169. "{{{ Todo List Mode
  170.  
  171. function! TodoListMode()
  172.   e ~/.todo.otl
  173.   Calendar
  174.   wincmd l
  175.   set foldlevel=1
  176.   tabnew ~/.notes.txt
  177.   tabfirst
  178.   " or 'norm! zMzr'
  179. endfunction
  180.  
  181. "}}}
  182.  
  183. "}}}
  184.  
  185. "{{{ Mappings
  186.  
  187. " Open Url on this line with the browser \w
  188. map <Leader>w :call Browser ()<CR>
  189.  
  190. " Open the Project Plugin <F2>
  191. nnoremap <silent> <F2> :Project<CR>
  192.  
  193. " Open the Project Plugin
  194. nnoremap <silent> <Leader>pal  :Project .vimproject<CR>
  195.  
  196. " TODO Mode
  197. nnoremap <silent> <Leader>todo :execute TodoListMode()<CR>
  198.  
  199. " Open the TagList Plugin <F3>
  200. nnoremap <silent> <F3> :Tlist<CR>
  201.  
  202. " Next Tab
  203. nnoremap <silent> <C-Right> :tabnext<CR>
  204.  
  205. " Previous Tab
  206. nnoremap <silent> <C-Left> :tabprevious<CR>
  207.  
  208. " New Tab
  209. nnoremap <silent> <C-t> :tabnew<CR>
  210.  
  211. " Rotate Color Scheme <F8>
  212. nnoremap <silent> <F8> :execute RotateColorTheme()<CR>
  213.  
  214. " DOS is for fools.
  215. nnoremap <silent> <F9> :%s/$//g<CR>:%s// /g<CR>
  216.  
  217. " Paste Mode!  Dang! <F10>
  218. nnoremap <silent> <F10> :call Paste_on_off()<CR>
  219. set pastetoggle=<F10>
  220.  
  221. " Edit vimrc \ev
  222. nnoremap <silent> <Leader>ev :tabnew<CR>:e ~/.vimrc<CR>
  223.  
  224. " Edit gvimrc \gv
  225. nnoremap <silent> <Leader>gv :tabnew<CR>:e ~/.gvimrc<CR>
  226.  
  227. " Up and down are more logical with g..
  228. nnoremap <silent> k gk
  229. nnoremap <silent> j gj
  230. inoremap <silent> <Up> <Esc>gka
  231. inoremap <silent> <Down> <Esc>gja
  232.  
  233. " Good call Benjie (r for i)
  234. nnoremap <silent> <Home> i <Esc>r
  235. nnoremap <silent> <End> a <Esc>r
  236.  
  237. " Create Blank Newlines and stay in Normal mode
  238. nnoremap <silent> zj o<Esc>
  239. nnoremap <silent> zk O<Esc>
  240.  
  241. " Space will toggle folds!
  242. nnoremap <space> za
  243.  
  244. " Search mappings: These will make it so that going to the next one in a
  245. " search will center on the line it's found in.
  246. map N Nzz
  247. map n nzz
  248.  
  249. " Testing
  250. set completeopt=longest,menuone,preview
  251.  
  252. inoremap <expr> <cr> pumvisible() ? "\<c-y>" : "\<c-g>u\<cr>"
  253. inoremap <expr> <c-n> pumvisible() ? "\<lt>c-n>" : "\<lt>c-n>\<lt>c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<lt>cr>"
  254. inoremap <expr> <m-;> pumvisible() ? "\<lt>c-n>" : "\<lt>c-x>\<lt>c-o>\<lt>c-n>\<lt>c-p>\<lt>c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<lt>cr>"
  255.  
  256. " Fix email paragraphs
  257. nnoremap <leader>par :%s/^>$//<CR>
  258.  
  259. "ly$O#{{{ "lpjjj_%A#}}}jjzajj
  260.  
  261. "}}}
  262.  
  263. "{{{Taglist configuration
  264. let Tlist_Use_Right_Window = 1
  265. let Tlist_Enable_Fold_Column = 0
  266. let Tlist_Exit_OnlyWindow = 1
  267. let Tlist_Use_SingleClick = 1
  268. let Tlist_Inc_Winwidth = 0
  269. "}}}
  270.  
  271. let g:rct_completion_use_fri = 1
  272. "let g:Tex_DefaultTargetFormat = "pdf"
  273. let g:Tex_ViewRule_pdf = "kpdf"
  274.  
  275. filetype plugin indent on
  276. syntax on
  277. set bg=dark
Advertisement
Add Comment
Please, Sign In to add comment