Skip to content

Instantly share code, notes, and snippets.

@berlincount
Last active May 12, 2017 16:30
Show Gist options
  • Save berlincount/7c645c4c580a7911c922e1acf69dc84c to your computer and use it in GitHub Desktop.
Save berlincount/7c645c4c580a7911c922e1acf69dc84c to your computer and use it in GitHub Desktop.
vimrc
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
set bs=2
set backup
set viminfo='20,\"50
set history=100
set ruler
""""set tw=78
set showmode
set showcmd
set showmatch
set ts=8
set shiftwidth=4
set magic
set ic
set vb t_vb=
set expandtab
set tabstop=8
""""set softtabstop=2
set smartindent
""""set smarttab
set list listchars=tab:»·,trail:··
set background=dark
syntax on
"""map ,, maa0<ESC>mbbma$a x<ESC>`awgebi(<ESC>ea)<ESC>$xx`blx`a
"""map ;; maa0<ESC>mbbma$a x<ESC>`awgebi{<ESC>ea}<ESC>$xx`blx`a
"""map -- maa0<ESC>mbbma$a x<ESC>`awgebi[<ESC>ea]<ESC>$xx`blx`a
"""set cinkeys=0{,0},:,0#,!^F,o,O,e·
"""set cinwords=if,else,while,do,for,switch,case
" Make p in Visual mode replace the selected text with the "" register.
"""vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>
if has("autocmd")
autocmd FileType text setlocal tw=78
autocmd FileType pl,pm set formatoptions=croql cindent comments=b:#
augroup cprog
au!
autocmd FileType * set formatoptions=tcql nocindent comments&
autocmd FileType c,cpp set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://·
augroup END
if 0
autocmd BufReadPost * if line("'\"") && line("'\"") <= line("$")
| exe "normal `\""·
| endif
endif
"""endif has("autocmd")
"automatisches Ausführen des map: } führt zu "k2cc"
"map! } <ESC>k2cc
"set cinoptions=>s,e0,n0,f0,{0,}0,^0,:s,=s,ps,ts,c3,+s,(2s,us,)20,*30,gs,hs
"""set cinoptions={.5s,:.5s,+.5s,t0,g0,^-2,e-2,n-2,p2s,(0,=.5s,f0
"au BufReadPost * if line("'\"") | execute("normal `\"") | endif
let c_space_errors=1
augroup encrypted
au!
" First make sure nothing is written to ~/.viminfo while editing
" an encrypted file.
autocmd BufReadPre,FileReadPre *.gpg,*.asc set viminfo=
" We don't want a swap file, as it writes unencrypted data to disk.
autocmd BufReadPre,FileReadPre *.gpg,*.asc set noswapfile
" Switch to binary mode to read the encrypted file.
autocmd BufReadPre,FileReadPre *.gpg set bin
autocmd BufReadPre,FileReadPre *.gpg,*.asc let ch_save = &ch|set ch=2
autocmd BufReadPost,FileReadPost *.gpg,*.asc
\ '[,']!sh -c 'gpg --decrypt 2> /dev/null'
" Switch to normal mode for editing
autocmd BufReadPost,FileReadPost *.gpg set nobin
autocmd BufReadPost,FileReadPost *.gpg,*.asc let &ch = ch_save|unlet ch_save
autocmd BufReadPost,FileReadPost *.gpg,*.asc
\ execute ":doautocmd BufReadPost " . expand("%:r")
" Convert all text to encrypted text before writing
autocmd BufWritePre,FileWritePre *.gpg
\ '[,']!sh -c 'gpg --default-recipient-self -e 2>/dev/null'
autocmd BufWritePre,FileWritePre *.gpg set bin
autocmd BufWritePre,FileWritePre *.asc
\ '[,']!sh -c 'gpg --default-recipient-self -e -a 2>/dev/null'
" Undo the encryption so we are back in the normal text, directly
" after the file has been written.
autocmd BufWritePost,FileWritePost *.gpg,*.asc u
autocmd BufWritePost,FileWritePost *.gpg set nobin
augroup END
augroup JumpCursorOnEdit
au!
autocmd BufReadPost *
\ if expand("<afile>: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·
filetype plugin indent on
syntax enable
" Vim needs to be built with Python scripting support, and must be
" able to find Merlin's executable on PATH.
if executable('ocamlmerlin') && has('python')
let s:ocamlmerlin = substitute(system('opam config var share'), '\n$', '', '''') . "/ocamlmerlin"
execute "set rtp+=".s:ocamlmerlin."/vim"
execute "set rtp+=".s:ocamlmerlin."/vimbufsync"
endif
let g:syntastic_ocaml_checkers=['merlin']
autocmd FileType ocaml source substitute(system('opam config var share'), '\n$', '', '''') . "/typerex/ocp-indent/ocp-indent.vim"
colorscheme darkblue
ca w!! w !sudo tee > /dev/null "%"
" from .vim/autload/pathogen.vim
" .. loads .vim/bundle stuff (syntastic vim-go vim-wakatime vimoutliner)
execute pathogen#infect()
set directory=~/.vim/swap//
set undodir=~/.vim/undo//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment