Last active
October 10, 2015 19:38
-
-
Save jonatasnona/3741100 to your computer and use it in GitHub Desktop.
VIM: vimrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Vim Pathogen | |
runtime bundle/vim-pathogen/autoload/pathogen.vim | |
call pathogen#infect() | |
call pathogen#helptags() | |
" ############################################## | |
" # General Settings # | |
" ############################################## | |
if has ('cmdline_info') | |
" show the ruler | |
set ruler | |
" a ruler on steroids | |
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) | |
" show partial commands in status line and | |
" selected characters/lines in visual mode | |
set showcmd | |
endif | |
if has('statusline') | |
set laststatus=2 | |
" broken down into easily includeable segments | |
" | |
" filename | |
set statusline=%<%f\ | |
" options | |
set statusline+=%w%h%m%r | |
" git hotness | |
" set statusline+=%{fugitive#statusline()} | |
" filetype | |
set statusline+=\ [%{&ff}/%Y] | |
" current dir | |
set statusline+=\ [%{getcwd()}] | |
" right aligned file nav info | |
set statusline+=%=%-14.(%l,%c%V%)\ %p%% | |
endif | |
" enable wrap linebreak and nolist to see big texts on small screens | |
command! -nargs=* Readability set wrap linebreak nolist | |
" disable highlighted search on insert mode | |
au InsertEnter * :let @/="" | |
" restore cursor position | |
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif | |
" set smartindent | |
au FileType cpp,c,java,sh,pl,php,html,xml,javascript,ruby set smartindent | |
set completeopt=menuone,menu,longest,preview | |
set viewoptions=folds,options,cursor,unix,slash | |
set shortmess+=filmnrxoOtT | |
set nojoinspaces | |
set backspace=indent,eol,start " backspace for dummies | |
set wildmode=list:longest,full " command <Tab> completion, list matches, then longest common part, then all. | |
set whichwrap=b,s,h,l,<,>,[,] " backspace and cursor keys wrap to | |
set textwidth=79 " wrap on 79 | |
set nocompatible " using vim, not vi. | |
set noswapfile " no swap files | |
set history=100 " keep 100 lines of history | |
set background=dark " assume a dark background | |
set t_Co=256 " assume 256 colors | |
set title " show title in console title bar | |
set virtualedit=onemore " allow for cursor beyond last character | |
set hidden " allow buffer switching without saving | |
set tabpagemax=10 " only show 10 tabs | |
set showmode " display the current mode | |
set cursorline " highlight current line | |
set gfn=Ubuntu\ Mono\ 20 " set Ubuntu Mono font as default font | |
" set mouse=a " enable mouse usage | |
set exrc " enable per-directory .vimrc files | |
set secure " disable unsafe commands in local .vimrc files | |
set linespace=0 " no extra spaces between rows | |
set nu " line numbers on | |
set showmatch " show matching brackets/parenthesis | |
set incsearch " find as you type | |
set hlsearch " highlight search terms | |
set winminheight=0 " windows can be 0 line high | |
set smartcase " case sensitive when uc present | |
set wildmenu " show list instead of just completing | |
set wildignore=*.o,*~,*.pyc " show list instead of just completing | |
set scrolloff=3 " minimum lines to keep above and below cursor | |
set foldenable " auto fold code | |
set nowrap " wrap long lines | |
set autoindent " indent at the same level of the previous line | |
set shiftwidth=4 " use indents of 4 spaces | |
set expandtab " tabs are spaces, not tabs | |
set tabstop=4 " an indentation every four columns | |
set softtabstop=4 " let backspace delete indent | |
syntax enable " syntax highlighting | |
colorscheme molokai " change to slate or elford | |
filetype plugin on " to work with NerdCommenter | |
scriptencoding utf-8 " utf-8 as default encoding | |
"set spell " spell checking on | |
"filetype plugin indent on " automatically detect file types | |
"set list " show tab, space chars | |
"set listchars=tab:,.,trail:.,extends:#,nbsp:. " highlight problematic whitespace | |
" ############################################## | |
" # Keys Mapping # | |
" ############################################## | |
" build my own tags of my projects | |
noremap <F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr> | |
inoremap <F12> <Esc>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr> | |
" key shortcut to remove trainling whitespaces | |
nnoremap <silent> <F5> :%s,\s\+$,,<CR> | |
" key shortcuts for comments/uncomments | |
nnoremap <silent> <c-c> :s,^,<C-R>=comment<CR>,<CR>:noh<CR> | |
nnoremap <silent> <c-u> :s,^\V<C-R>=comment<CR>,,e<CR>:noh<CR> | |
" key shortcuts for switching tabs | |
nnoremap <C-Left> :tabprevious<CR> | |
nnoremap <C-Right> :tabnext<CR> | |
" wrapped lines goes down/up to next row, rather than next line in file | |
nnoremap j gj | |
nnoremap k gk | |
" adjust viewports to the same size | |
map <Leader>= <C-w>= | |
" single compile keys | |
nmap <F9> :SCCompileRun<cr> | |
" code folding options | |
nmap <leader>f0 :set foldlevel=0<CR> | |
" Toggle Shell Pasting | |
nnoremap <F2> :set invpaste paste?<cr> | |
set pastetoggle=<F2> | |
" Select all. | |
map <c-a> ggVG | |
" ############################################## | |
" # Languages Syntax Settings # | |
" ############################################## | |
" configuring omni css | |
autocmd FileType css set omnifunc=csscomplete#CompleteCSS | |
" comment/uncomment for different languages | |
au FileType sh,make,python let comment = '# ' | |
au FileType c,cpp,java,javascript,php let comment = '// ' | |
au FileType tex let comment = '% ' | |
au FileType vim let comment = '" ' | |
" C++ | |
au FileType c,cpp,objc,objcpp set syntax=cpp11 | call CSyntaxAfter() | |
au BufNewFile,BufRead * | |
\if expand('%:e') =~ '^\(h\|hh\|hxx\|hpp\|ii\|ixx\|ipp\|inl\|txx\|tpp\|tpl\|cc\|cxx\|cpp\)$' | | |
\ if &ft != 'cpp' | |
\ set ft=cpp | |
\ endif | |
\endif | |
" configuring tags for c and cpp | |
set tags+=~/.vim/tags/stl | |
set tags+=~/.vim/tags/gl | |
set tags+=~/.vim/tags/cairo | |
set tags+=~/.vim/tags/gtk2 | |
set tags+=~/.vim/tags/gtk3 | |
set tags+=~/.vim/tags/libxml2 | |
" ominicppcomplete | |
let OmniCpp_NamespaceSearch = 1 | |
let OmniCpp_GlobalScopeSearch = 1 | |
let OmniCpp_ShowAccess = 1 | |
let OmniCpp_MayCompleteDot = 1 | |
let OmniCpp_MayCompleteArrow = 1 | |
let OmniCpp_MayCompleteScope = 1 | |
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"] | |
" ############################################## | |
" # NERDTree Settings # | |
" ############################################## | |
" Map NERDTreeToggle to convenient key | |
nnoremap <silent> <c-n> :NERDTreeToggle<cr> | |
" Prevent :bd inside NERDTree buffer | |
au FileType nerdtree cnoreabbrev <buffer> bd <nop> | |
au FileType nerdtree cnoreabbrev <buffer> BD <nop> | |
" bufkill bd's: really do not mess with NERDTree buffer | |
nnoremap <silent> <backspace> :BD<cr> | |
nnoremap <silent> <s-backspace> :BD!<cr> | |
" ############################################## | |
" # Another Settings # | |
" ############################################## | |
" zen coding remap keys | |
let g:user_zen_expandabbr_key='<c-e>' | |
autocmd BufEnter * if bufname("") !~ "^\[A-Za-z0-9\]*://" | lcd %:p:h | endif | |
" automatically open and close the popup menu / preview window | |
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent!pclose|endif | |
" highlight trainling whitespaces | |
highlight WhitespaceEOL ctermbg=red guibg=red | |
match WhitespaceEOL /\s\+$/ | |
" remove trailing whitespaces and ^M chars | |
autocmd FileType c,cpp,java,php,js,python,twig,xml,yml,html autocmd BufWrite <buffer> :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")')) | |
" change working directory to that of the current file | |
cmap cwd lcd %:p:h | |
cmap cd. lcd %:p:h | |
" fix home and end keybindings for screen, particularly on mac | |
map ^[[F $ | |
imap ^[[F ^O$ | |
map ^[[H g0 | |
imap ^[[H ^Og0 | |
" highlight as Error characters beyond column 80 | |
command Hl80 :match Error /\%>80c/ | |
command Nohl80 :match None /\%>80c/ | |
" airline configuration | |
"let g:airline_left_sep='➲' | |
let g:airline_left_sep='' | |
let g:airline_right_sep='' | |
"let g:airline_branch_prefix='ᚺ' | |
"let g:airline_branch_prefix='⇈' | |
let g:airline_branch_prefix='♆' | |
"let g:airline_powerline_fonts = 1 | |
"let g:airline_left_sep='〉 ' | |
"let g:airline_right_sep='' | |
let g:airline_theme='kira' | |
" tagbar | |
nmap <F8> :TagbarToggle<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment