Skip to content

Instantly share code, notes, and snippets.

@nkammah
Created February 6, 2018 18:15
Show Gist options
  • Save nkammah/fe4e895fb1da2f00c372579b6b3f7ddf to your computer and use it in GitHub Desktop.
Save nkammah/fe4e895fb1da2f00c372579b6b3f7ddf to your computer and use it in GitHub Desktop.
.vimrc
filetype off
filetype plugin indent on
set nocompatible " We're running Vim, not Vi!
syntax on " Enable syntax highlighting
set ff=unix
set backspace=indent,eol,start
" colors
syntax enable
set background=dark
set showmode " display the current mode
hi cursorline guibg=#333333 " highlight bg color of current line
hi CursorColumn guibg=#333333 " highlight cursor
" highlight OverLength ctermbg=red ctermfg=white guibg=#592929
" match OverLength /\%81v.\+/
" tabspacing
set tabstop=4
set shiftwidth=4
set expandtab
set autoindent
set paste
set ttyfast
set noswapfile
set nobackup
set nowritebackup
set enc=utf-8
set fencs=utf-8
set visualbell t_vb=
set history=1000
set undolevels=1000
set wildmenu
set winwidth=300
set winminwidth=50
set tabpagemax=80
set showcmd " show partial commands in status line and selected characters/lines in visual mode
set autoread " Set to auto read when a file is changed from the outside
" search options
set hlsearch " highlight search results
set incsearch " find as you type search
set ignorecase
set smartcase " case sensitive when upper case present
set nonu " line number
set showmatch
" remap leader to comma
let mapleader=","
" find out who's to blame for the current line
vmap <leader>g :<C-U>!git blame <C-R>=expand("%:p") <CR> \| sed -n <C-R>=line("'<") <CR>,<C-R>=line("'>") <CR>p <CR>
" strip trailing whitespace
"nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
function! <SID>StripTrailingWhitespace()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
nmap <silent> <Leader><space> :call <SID>StripTrailingWhitespace()<CR>
" Phpcs functions ( syntastic is way to slow
" run with :Phpcs followed by :cope
function! RunPhpcs()
let l:filename=@%
let l:phpcs_output=system('phpcs --report=full --standard=/home/nkammah/development/Etsyweb/tests/standards/stable-ruleset.xml '.l:filename)
let l:phpcs_list=split(l:phpcs_output, "\n")
unlet l:phpcs_list[0]
cexpr l:phpcs_list
cwindow
endfunction
set errorformat+=\"%f\"\\,%l\\,%c\\,%t%*[a-zA-Z]\\,\"%m\"
command! Phpcs execute RunPhpcs()
""""""""""""""""""""""""""""""
" => Status line
""""""""""""""""""""""""""""""
" Always show the status line
set laststatus=2
" Format the status line
set statusline=\ %F%m%r%h\ %w\ \ Line:\ %l\ /\ %L
if has('mouse')
set mouse=a
if &term =~ "xterm" || &term =~ "screen"
" for some reason, doing this directly with 'set ttymouse=xterm2'
" doesn't work -- 'set ttymouse?' returns xterm2 but the mouse
" makes tmux enter copy mode instead of selecting or scrolling
" inside Vim -- but luckily, setting it up from within autocmds
" works
autocmd VimEnter * set ttymouse=xterm2
autocmd FocusGained * set ttymouse=xterm2
autocmd BufEnter * set ttymouse=xterm2
endif
endif
set clipboard=unnamed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment