Skip to content

Instantly share code, notes, and snippets.

@cpelley
Last active December 22, 2015 00:59
Show Gist options
  • Save cpelley/6393439 to your computer and use it in GitHub Desktop.
Save cpelley/6393439 to your computer and use it in GitHub Desktop.
" ENABLE FILETYPE SPECIFIC VIM SETTINGS FILES
filetype plugin on
" language-dependent indenting.
filetype plugin indent on
" SET COLOUR
" mkdir -p ~/.vim/colors && cd ~/.vim/colors
" wget -O wombat256mod.vim http://www.vim.org/scripts/download_script.php?src_id=13400
set t_Co=256
try
color wombat256mod
catch /^Vim\%((\a\+)\)\=:E185/
endtry
" F2 to paste code without autoindentation
set pastetoggle=<F2>
syntax on
set number
" Change backspace behaviour (default deletes as far back as insert only)
set backspace=2
" Useful settings
set history=700
set undolevels=700
" Disable backup and swap files
set nobackup
set nowritebackup
set noswapfile
" highlight all
set hlsearch
" stop startup message
set shortmess+=I
" Enable sessions
set sessionoptions=buffers
" tab completion for file open
set wildmode=longest,list
set wildmenu
" bind Ctrl+<movement> keys to move around the windows, instead of using
" Ctrl+w + <movement>
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
" Rebind <Leader> key
let mapleader = ","
" Delete before and after current cursor position
map <Leader>k d$
map <Leader>u d^
" easier moving between tabs
map <Leader>n <esc>:tabprevious<CR>
map <Leader>m <esc>:tabnext<CR>
" spellcheck
map <F6> <Esc>:setlocal spell spelllang=en_gb<CR>
map <F7> <Esc>:setlocal nospell<CR>
" Remove highlight of last search
noremap <C-n> :nohl<CR>
vnoremap <C-n> :nohl<CR>
inoremap <C-n> :nohl<CR>
" Setup Pathogen to manage plugins
" " mkdir -p ~/.vim/autoload ~/.vim/bundle
" " wget https://raw.github.com/tpope/vim-pathogen/HEAD/autoload/pathogen.vim
" " Now you can install any plugin into a .vim/bundle/plugin-name/ folder
call pathogen#infect()
" statusline customisation
" ========================
" always show statusline
set laststatus=2
function! InsertStatuslineColor(mode)
if a:mode == 'i'
hi statusline ctermbg=52
elseif a:mode == 'r'
hi statusline ctermbg=24
else
hi statusline ctermbg=54
endif
endfunction
au InsertEnter * call InsertStatuslineColor(v:insertmode)
au InsertChange * call InsertStatuslineColor(v:insertmode)
au InsertLeave * hi statusline ctermfg=white ctermbg=241
" default the statusline to green when entering Vim
hi statusline ctermfg=white ctermbg=241
" http://got-ravings.blogspot.co.uk/2008/08/vim-pr0n-making-statuslines-that-own.html
set statusline=%t[%{strlen(&fenc)?&fenc:'none'},%{&ff}]%h%m%r%y%=%c,%l/%L\ %P
" number of screen lines to keep above and below the cursor - scrolling
set scrolloff=10
" handling whitespace hide/show/delete
" ===================
highlight WhitespaceHL ctermbg=yellow guibg=yellow
nnoremap <Leader>w :match WhitespaceHL /\s\+$/<CR>
nnoremap <Leader>wh :match<CR>
nnoremap <Leader>wd :%s/\s\+$//<CR>:match<CR>:nohl<CR>
" refresh buffer
command Refresh :call Refresh()
function! Refresh()
set noconfirm
bufdo e!
set confirm
endfunction
" tmp go to terminal
command Terminal :call Terminal()
function! Terminal()
:lcd %:p:h
:!bash
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment