Skip to content

Instantly share code, notes, and snippets.

@rotespferd
Created July 10, 2012 21:57
Show Gist options
  • Save rotespferd/3086486 to your computer and use it in GitHub Desktop.
Save rotespferd/3086486 to your computer and use it in GitHub Desktop.
My .vimrc
" use hukl's dotfiles
" use http://www.vim.org/scripts/script.php?script_id=2754
set nocompatible
" Initialize Pathogen
call pathogen#infect()
" Enable syntax highlighting
syntax on
filetype plugin indent on
" Colorscheme see https://github.com/hukl/Smyck-Color-Scheme
color smyck
" Add line numbers
set number
set ruler
" Set encoding
set encoding=utf-8
" Whitespace stuff
set nowrap
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
" Show trailing spaces and highlight hard tabs
set list listchars=tab:»·,trail:·
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" Strip trailing whitespaces on each save
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
" Search related settings
set incsearch
set hlsearch
" Map Ctrl+l to clear highlighted searches
nnoremap <silent> <C-l> :<C-u>nohlsearch<CR><C-l>
" Highlight characters behind the 80 chars margin
:au BufWinEnter * let w:m2=matchadd('ColumnMargin', '\%>80v.\+', -1)
" Disable code folding
set nofoldenable
" Directories for swp files
set backupdir=~/.vimbackup
set directory=~/.vimbackup
" NERDTree configuration
let NERDTreeIgnore=['\.pyc$', '\.rbc$', '\~$']
map <Leader>n :NERDTreeToggle<CR>
" make uses real tabs
au FileType make set noexpandtab
" Erlang uses 4 spaces
au FileType erlang set softtabstop=4 tabstop=4 shiftwidth=4
" Thorfile, Rakefile, Vagrantfile and Gemfile are Ruby
au BufRead,BufNewFile {Gemfile,Rakefile,Vagrantfile,Thorfile,config.ru} set ft=ruby
" md, markdown, and mk are markdown and define buffer-local preview
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn} call s:setupMarkup()
" add json syntax highlighting
au BufNewFile,BufRead *.json set ft=javascript
au BufRead,BufNewFile *.txt call s:setupWrapping()
" make Python follow PEP8 ( http://www.python.org/dev/peps/pep-0008/ )
au FileType python set softtabstop=4 tabstop=4 shiftwidth=4 textwidth=79
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" ctrp custom ignores
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.hg$\|\.svn$\|\.eunit$',
\ 'file': '\.exe$\|\.so$\|\.dll\|\.beam$\|\.DS_Store$'
\ }
function! Smart_TabComplete()
let line = getline('.') " current line
let substr = strpart(line, -1, col('.')+1) " from the start of the current
" line to one character right
" of the cursor
let substr = matchstr(substr, "[^ \t]*$") " word till cursor
if (strlen(substr)==0) " nothing to match on empty string
return "\<tab>"
endif
let has_period = match(substr, '\.') != -1 " position of period, if any
let has_slash = match(substr, '\/') != -1 " position of slash, if any
if (!has_period && !has_slash)
return "\<C-X>\<C-P>" " existing text matching
elseif ( has_slash )
return "\<C-X>\<C-F>" " file matching
else
return "\<C-X>\<C-O>" " plugin matching
endif
endfunction
inoremap <tab> <c-r>=Smart_TabComplete()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment