Skip to content

Instantly share code, notes, and snippets.

@jrtaylor-com
Last active June 8, 2017 11:21
Show Gist options
  • Save jrtaylor-com/0c1a4cee9097ed185c25 to your computer and use it in GitHub Desktop.
Save jrtaylor-com/0c1a4cee9097ed185c25 to your computer and use it in GitHub Desktop.
"set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'tpope/vim-sleuth'
Bundle 'joonty/vdebug.git'
call vundle#end()
filetype plugin indent on
set number
set ruler
set ignorecase
set smartcase
set hlsearch
set incsearch
set showmatch
set mat=2
set noerrorbells
set novisualbell
set t_vb=
set tm=500
set hidden
syntax enable
colorscheme desert
set background=dark
set encoding=utf8
set ffs=unix,dos,mac
set tabstop=4
set expandtab
set shiftwidth=4
set laststatus=2
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l
" Returns true if paste mode is enabled
function! HasPaste()
if &paste
return 'PASTE MODE '
en
return ''
endfunction
" Add ctrlp.vim setting
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/vendor/*,*/\.git/*
let g:ctrlp_custom_ignore = {
\ 'dir': 'tmp$\|\.git$\|\.hg$\|\.svn$\|.rvm$|.bundle$\|vendor',
\ 'file': '\v\.(exe|so|dll|class|png|jpg|jpeg)$',
\}
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_match_window_bottom=1
let g:ctrlp_match_window_reversed=0
let g:ctrlp_mruf_max=500
let g:ctrlp_clear_cache_on_exit=0
" Speed up indexing/search
" Requires ack - yum install ack
" Requires ag https://gist.github.com/rkaneko/988c3964a3177eb69b75
let g:ctrlp_user_command = 'ag %s -i --nocolor --nogroup --hidden
\ --ignore .git
\ --ignore .svn
\ --ignore .hg
\ --ignore .DS_Store
\ --ignore "**/*.pyc"
\ -g ""'
" Twig template syntax
au BufRead,BufNewFile *.twig set filetype=htmljinja
" tab numbers
" Rename tabs to show tab number.
" (Based on http://stackoverflow.com/questions/5927952/whats-implementation-of-vims-default-tabline-function)
if exists("+showtabline")
function! MyTabLine()
let s = ''
let wn = ''
let t = tabpagenr()
let i = 1
while i <= tabpagenr('$')
let buflist = tabpagebuflist(i)
let winnr = tabpagewinnr(i)
let s .= '%' . i . 'T'
let s .= (i == t ? '%1*' : '%2*')
let s .= ' '
let wn = tabpagewinnr(i,'$')
let s .= '%#TabNum#'
let s .= i
" let s .= '%*'
let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
let bufnr = buflist[winnr - 1]
let file = bufname(bufnr)
let buftype = getbufvar(bufnr, 'buftype')
if buftype == 'nofile'
if file =~ '\/.'
let file = substitute(file, '.*\/\ze.', '', '')
endif
else
let file = fnamemodify(file, ':p:t')
endif
if file == ''
let file = '[No Name]'
endif
let s .= ' ' . file . ' '
let i = i + 1
endwhile
let s .= '%T%#TabLineFill#%='
let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X')
return s
endfunction
set stal=2
set tabline=%!MyTabLine()
set showtabline=1
highlight link TabNum Special
endif
" Return indent (all whitespace at start of a line), converted from
" tabs to spaces if what = 1, or from spaces to tabs otherwise.
" When converting to tabs, result has no redundant spaces.
function! Indenting(indent, what, cols)
let spccol = repeat(' ', a:cols)
let result = substitute(a:indent, spccol, '\t', 'g')
let result = substitute(result, ' \+\ze\t', '', 'g')
if a:what == 1
let result = substitute(result, '\t', spccol, 'g')
endif
return result
endfunction
" Convert whitespace used for indenting (before first non-whitespace).
" what = 0 (convert spaces to tabs), or 1 (convert tabs to spaces).
" cols = string with number of columns per tab, or empty to use 'tabstop'.
" The cursor position is restored, but the cursor will be in a different
" column when the number of characters in the indent of the line is changed.
function! IndentConvert(line1, line2, what, cols)
let savepos = getpos('.')
let cols = empty(a:cols) ? &tabstop : a:cols
execute a:line1 . ',' . a:line2 . 's/^\s\+/\=Indenting(submatch(0), a:what, cols)/e'
call histdel('search', -1)
call setpos('.', savepos)
endfunction
command! -nargs=? -range=% Space2Tab call IndentConvert(<line1>,<line2>,0,<q-args>)
command! -nargs=? -range=% Tab2Space call IndentConvert(<line1>,<line2>,1,<q-args>)
command! -nargs=? -range=% RetabIndent call IndentConvert(<line1>,<line2>,&et,<q-args>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment