vim-configs / vimrc

Full commit
"| Author: Domantas Jackūnas <>                                |
"| Source:                            |

" Load pathogen and plugins                                                {{{
filetype off
filetype plugin on
filetype plugin indent off

call pathogen#runtime_append_all_bundles()
call pathogen#helptags()

filetype on
filetype plugin on
" }}}
" VIM behaviour                                                            {{{
" Display non printable chars on leader+s on/off
set listchars=tab:»»,trail:·,extends:#,nbsp:·,eol:$

" Show (partial) command in the last line of the screen.
set showcmd

" GUI settings
set title

" Don't update the display while executing macros
set lazyredraw

" Always display a status line at the bottom of the window
set laststatus=2

" Keep 3 lines visible down from the cursor while scrolling
set scrolloff=3

" Enable ctags support
set tags=./tags;/

" Pyflake settings
highlight SpellBad ctermfg=blue
let g:pyflakes_use_quickfix = 0

" If file is not modified in VIM but changed outside, reload it
set autoread

" Keep commands history longer (by default keeps only 20 commands)
set history=1000

" Shows information on VIM bottom
set ruler

" Show line numbers in editor
set number

" Ignore case in search and replace
set ignorecase

" Found text will be highlighted and search will be repeated over file
set incsearch

" Smart search: if lowercase ignore case of matches, if not case-sensitive
" search
set smartcase

" Keep VIM history even file is closed
set viminfo='20,<50,s10,h

" Remove trailing spaces after save
au BufWritePre * silent g/\s\+$/s///
" }}}
" Edit behaviour                                                           {{{
" Mapleader from \ to ,
let mapleader=","

" Enable syntax highlighting
syntax on

" Encoding
set termencoding=utf-8
set encoding=utf-8

" Set tab to 4 spaces
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab

" Enable wrap mode to see long code lines
set wrap
set textwidth=0

" Enable mouse features
set mouse=a

" For new lines automatically indent by current line indent
set autoindent
set copyindent

" Show matching for symbols like () and etc.
set showmatch

" Allow cursor to go in to 'invalid' places
set virtualedit=all

" Allow backspace on everything in insert mode
set backspace=indent,eol,start

" Word wrap not in the middle of the word
set formatoptions=l
set lbr
" }}}
" Backups and swap                                                         {{{
set backup
set backupdir=~/.vim/backup
set noswapfile
" }}}
" Mappings                                                                 {{{
" <SHIFT + t> - trim white spaces in lines end
map <s-t> :%s/ \+$//g<CR>

" Runs Unit tests
nmap <F8> :python RunUnitTestsUnderCursor()<CR>

" Toggles non printable character visibility
nmap <silent> <leader>w :set nolist!<CR>

" Use the damn hjkl keys
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>

" Allow to overwrite root protected files (in case of missed sudo)
cmap w!! %!sudo tee > /dev/null %

" Toggle NERDtree
map <leader>n :NERDTreeToggle<CR>

" Spell Check
map <F5> <Esc>:setlocal spell spelllang=lt<CR>
map <F6> <Esc>:setlocal spell spelllang=en_us<CR>
map <F7> <Esc>:setlocal nospell<CR>

" No autoindent in paste mode
set pastetoggle=<F2>

" PEP8 Check
let g:pep8_map='<F3>'
" }}}
" File types options                                                       {{{
" Ignore these file types on :e
set wildmenu
set wildmode=list:longest
set wildignore=*.swp,*.bak,*.pyc

" If VIM founds project.vim file in project root, it will be loaded.
" This is required if project has specific settings.
silent! source project.vim
" }}}
" Omnicomplete                                                             {{{
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS

set completeopt=menuone,longest
" }}}
" Colors                                                                   {{{
" Set Color scheme
colorscheme evening

" Enable CursorLine
set cursorline

" Default Colors for CursorLine
highlight  CursorLine   cterm=NONE ctermbg=darkblue ctermfg=white guibg=darkblue guifg=white

" Change Color when entering Insert Mode
autocmd InsertEnter * highlight  CursorLine   cterm=NONE ctermbg=green ctermfg=white guibg=green guifg=white

" Revert Color to default when leaving Insert Mode
autocmd InsertLeave * highlight  CursorLine   cterm=NONE ctermbg=darkblue ctermfg=white guibg=darkblue guifg=white

" Set different cursos line in insert mode
if &term =~ "xterm\\|rxvt"
    " use an orange cursor in insert mode
    let &t_SI = "\<Esc>]12;orange\x7"
    " use a gray cursor otherwise
    let &t_EI = "\<Esc>]12;gray\x7"
    silent !echo -ne "\033]12;gray\007"
    " reset cursor when vim exits
    autocmd VimLeave * silent !echo -ne "\033]112\007"
    " use \003]12;gray\007 for gnome-terminal

" Paint 80 symbols line
set colorcolumn=80
highlight  colorcolumn  cterm=NONE ctermbg=white ctermfg=blue guibg=white guifg=blue

" Omnicomplete colors
highlight  Pmenu   cterm=NONE ctermbg=darkblue ctermfg=white guibg=darkblue guifg=white
" }}}
" Mini Buff Explorer                                                       {{{
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
" }}}

function! HgCiDiff()
    "In .hgrc editor option I call vim "+HgCiDiff()"
    "It opens new split with diff inside
    rightbelow  vnew
    :.!hg diff
    set ft=diff
    saveas! /tmp/hgdiff.txt
    execute "normal \<c-w>w"