Skip to content

Instantly share code, notes, and snippets.

@Benedikt1992
Last active June 26, 2016 12:02
Show Gist options
  • Save Benedikt1992/6edd31cea3b77434b3a5 to your computer and use it in GitHub Desktop.
Save Benedikt1992/6edd31cea3b77434b3a5 to your computer and use it in GitHub Desktop.
Vim config
set mouse-=a
scriptencoding utf-8
set encoding=utf-8
set nocompatible " be iMproved, required
filetype off " required by Vundle
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
" call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Plugins
Plugin 'vim-scripts/indentpython.vim' " Python improvements
"Plugin 'scrooloose/syntastic' " Improved Syntax Checks. List of available checkers: https://github.com/scrooloose/syntastic/wiki/Syntax-Checkers
Plugin 'chase/vim-ansible-yaml' " Improved Syntax Highlighting for ansible yaml dialect
Plugin 'MarcWeber/vim-addon-mw-utils' " dependency for snipmate
Plugin 'tomtom/tlib_vim' " dependency for snipmate
Plugin 'garbas/vim-snipmate' " vim auto completion for code snippets
Plugin 'honza/vim-snippets' " Code snippets for snipmate
Plugin 'rodjek/vim-puppet' " Formatting basd on puppet labs style guide
Plugin 'godlygeek/tabular' " improves vim-puppet
Plugin 'ntpeters/vim-better-whitespace' " Show and strip trailing whitespaces
Plugin 'zxiest/vim-ruby' " Editing and compiling ruby within vim
Plugin 'trusktr/seti.vim' " colorscheme
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
"Enable syntax highlighting
syntax on
"colorscheme seti
" Tell vim to remember certain things when we exit
" '10 : marks will be remembered for up to 10 previously edited files
" "100 : will save up to 100 lines for each register
" :20 : up to 20 lines of command-line history will be remembered
" % : saves and restores the buffer list
" n... : where to save the viminfo files
set viminfo='10,\"100,:20,%,n~/.viminfo
set ignorecase
set smartcase
set incsearch
set hlsearch
set cursorline
set showmode
set ruler
set showmatch
set nolist
set listchars=eol:$,tab:>>,nbsp:%
autocmd FileType yaml :setlocal nowrap
autocmd BufRead,BufNewFile *.md set filetype=markdown
autocmd BufRead,BufNewFile Rexfile set filetype=perl
set visualbell t_vb= "don't use sound. use visual flash instead
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set smarttab
set autoindent
set backspace=indent,eol,start
" Congifuration of syntastic
" set statusline+=%#warningmsg#
" set statusline+=%{SyntasticStatuslineFlag()}
" set statusline+=%*
" let g:syntastic_enable_signs=1
" let g:syntastic_quiet_messages = {'level': 'warnings'}
" let g:syntastic_auto_loc_list=1
" F3: Toggle list (display unprintable characters)
nnoremap <F3> :set list! list?<CR>
"imap <Tab> <C-n>
"imap <S-Tab> <C-p>
nnoremap <F2> :set wrap! wrap?<CR>
set pastetoggle=<F4>
" make sure that the undo directory exists
":silent exec '!mkdir -p $HOME/.vim/undo'
set undofile " Save undo's after file closes
set undodir=$HOME/.vim/undo " where to save undo histories
set undolevels=1000 " How many undos
set undoreload=10000 " number of lines to save for undo
set nobackup
" Enable the auto alignment of EOL Comments
" Usage:
" inoremap <silent> EOLC_TOKEN EOLCTOKEN<Esc>:call <SID>ealigneolcomment(EOLC_TOKEN_REGEX)<CR>a
"
" EOLC_TOKEN: This is the character that initiates the end-of-line
" comment, e.g. "#". If there is more than one chaacter (e.g. "//") than
" try to use the last character.
" EOLC_TOKEN_REGEX: This is the regex that describes your EOLC_TOKEN.
" The regex has to be single quoted, e.g. "'#'" or "'\/\/'" (EOLC_TOKEN: "//")
"
" Example:
" inoremap <silent> # #<Esc>:call <SID>ealigneolcomment('#')<CR>a
" TODO:
" fix bug with multi character comment-tokens
" Restrict function call to specific files (e.g. '.rb')
" Comments starting with '"'
inoremap <silent> " "<Esc>:call <SID>ealigneolcomment('"')<CR>a
" Comments starting with '#'
inoremap <silent> # #<Esc>:call <SID>ealigneolcomment('#')<CR>a
" Comments starting with '//'
"inoremap <silent> / /<Esc>:call <SID>ealigneolcomment('\/\/')<CR>a
" The base function was developed by tpope
" https://gist.github.com/tpope/287147
function! s:ealigneolcomment(eolc_token)
let p = '^.\+'.a:eolc_token.'\s.*$'
echom p
if exists(':Tabularize') && getline('.') =~# '^.\+'.a:eolc_token.'$' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^'.a:eolc_token.']','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*'.a:eolc_token.'\s*\zs.*'))
let tab = '/[^'.a:eolc_token.'].*\zs'.a:eolc_token.'/l1'
execute ':Tabularize '.tab
normal! 0
call search(repeat('[^'.a:eolc_token.']*'.a:eolc_token,column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment