Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- " Auto update file when it is changed outside vim
- " TODO: does not work as it expected with nvim
- set autoread
- " Aesthetic line numeration
- set nu rnu
- " Leader Key
- let mapleader = ","
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Text, tab and indent related
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Use spaces instead of tabs
- set expandtab
- " Smart tabs
- set smarttab
- " 1 tab == 4 spaces
- set shiftwidth=4
- set tabstop=4
- " Linebreak on 500 characters
- set lbr
- set tw=500
- set ai " Auto indent
- set si " Smart indent
- set wrap " Wrap lines
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Autocompile, file format
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Run golang file
- au FileType go map <F8> :w <CR> : !clear; go run % <CR>
- " Auto pep8 for python (autopep8 is required)
- au FileType python map <F7> :w <CR> : !clear; autopep8 --in-place % <CR> :e <CR>
- " Run python3 file
- au FileType python map <F8> :w <CR> : !clear; python3 % <CR>
- " Auto format C/C++ file (clang-format is required)
- au FileType c,cpp,objc map <F7> :w <CR> : !clear; clang-format % >> temp.cpp; mv temp.cpp % <CR> :e <CR>
- " Build & run C++ file with g++ -std=c++11
- au FileType cpp map <F8> :w <CR> : !clear; ~/Projects/cpp/build_n_run_cpp11.sh % <CR>
- " Build & run C file with gcc -std=c99
- au FileType c map <F8> :w <CR> : !clear; ~/Projects/cpp/build_n_run_c99.sh % <CR>
- " Build & run C file with tcc
- au FileType c map <F9> :w <CR> : !clear; tcc -run -g % <CR>
- " Print int main() to C file
- function! CIntma()
- call append(line('^'), [ '#include <stdio.h>'
- \ , ''
- \ , 'int main(int argc, char *argv[]) {'])
- call append(line('$'), [ ' printf("Hello World");'
- \ , ' return 0;'
- \ , '}'])
- endfunction
- " :Intma function in .c files
- au FileType c command Intma :call CIntma()
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Plugins
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- set nocompatible " don't remember what it actually does
- " set the runtime path to include Vundle and initialize
- set rtp+=~/.vim/bundle/Vundle.vim
- call vundle#begin()
- " let Vundle manage Vundle, required
- Plugin 'gmarik/Vundle.vim'
- Plugin 'Valloric/YouCompleteMe'
- Plugin 'jiangmiao/auto-pairs'
- Plugin 'scrooloose/nerdtree'
- Plugin 'junegunn/fzf'
- Plugin 'tpope/vim-surround'
- Plugin 'junegunn/fzf.vim'
- highlight Pmenu ctermfg=0 ctermbg=15 guifg=#ffffff guibg=#707880
- " All of your Plugins must be added before the following line
- call vundle#end() " required
- filetype plugin indent on " required
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Autocomplete
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'
- let g:ycm_autoclose_preview_window_after_insertion = 1
- " Syntastic
- let g:syntastic_c_checkers=['make']
- let g:syntastic_always_populate_loc_list = 1
- let g:syntastic_check_on_open=1
- let g:syntastic_enable_signs=1
- let g:syntastic_error_symbol = '✗'
- let g:syntastic_warning_symbol = '⚠'
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Other shortcuts
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Open NERDTree with Ctrl-n
- " TODO: auto reload tree
- " Nwerd tree can be reloaded with r key or while reload
- map <C-n> :NERDTreeToggle<CR>:NERDTreeRefreshRoot<CR>
- let NERDTreeIgnore=['\.o$', '\.out$', '\.pyc$', '\~$']
- " split screen navigation
- nnoremap <C-J> <C-W><C-J>
- nnoremap <C-K> <C-W><C-K>
- nnoremap <C-L> <C-W><C-L>
- nnoremap <C-H> <C-W><C-H>
- " Smart search
- " silversearcher-ag required
- map <F4> :Ag<CR>
- " Disable bells
- set visualbell
- set t_vb=
- " Copy from vim - ctrl+c
- " Paste to vim - ctrl+p
- " gvim required
- vnoremap <C-c> "*y :let @+=@*<CR>
- map <C-p> "+P
- " Check spelling
- map <F6> :setlocal spell! spelllang=en_us<CR>
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " HTML leader combinations
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- au FileType html map <leader>b o<b></b><Space><Esc>FbT>i
- au FileType html map <leader>1 o<h1></h1><Esc>02f<i
- au FileType html map <leader>2 o<h2></h2><Esc>02f<i
- au FileType html map <leader>3 o<h3></h3><Esc>02f<i
- au FileType html map <leader>4 o<h4></h4><Esc>02f<i
- au FileType html map <leader>5 o<h5></h5><Esc>02f<i
- au FileType html map <leader>6 o<h6></h6><Esc>02f<i
- au FileType html map <leader>p o<p></p><Esc>02f<i
- au FileType html map <leader>a o<a href=""><++></a><Esc>0f"a
- au FileType html map <leader>im o<img src="" alt="<++>"<++>><Esc>0f"a
- au FileType html map <leader>it o<i></i><Esc>0f>a
- au FileType html map <leader>sm o<small></small><Esc>0f>a
- au FileType html map <leader>ma o<mark></mark><Esc>0f>a
- au FileType html map <leader>q o<q></q><Space><Esc>02f<i
- au FileType html map <leader>/ o<!-- --><Space><Esc>0f a
- au FileType html map <leader>ul o<ul><Enter><li></li><Enter></ul><Esc>0k2f<i
- au FileType html map <leader>li o<li></li><Esc>F>a
- au FileType html map <leader>ol o<ol><Enter><li></li><Enter></ol><Esc>0k2f<i
- inoremap <leader>c <Esc>/<++><Enter>"_c4l
- vnoremap <leader>c <Esc>/<++><Enter>"_c4l
- map <leader>c <Esc>/<++><Enter>"_c4l
- inoremap <leader>d <Esc>/<++><Enter>"_d4l
- vnoremap <leader>d <Esc>/<++><Enter>"_d4l
- map <leader>d <Esc>/<++><Enter>"_d4l
- " Print main to HTML file
- function! HTMLma()
- call append(line('^'), [ '<!DOCTYPE html>'
- \ , '<html>'
- \ , '<head>'
- \ , '<title><++></title>'
- \ , '</head>'
- \ , '<body>'])
- call append(line('$'), [ '</body>'
- \ , '</html>'])
- endfunction
- " :Intma function in .c files
- au FileType html command Intma :call HTMLma()
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " nvim color scheme
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- colorscheme darkblue
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Status line
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- set laststatus=2
- function! GitBranch()
- return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
- endfunction
- function! StatuslineGit()
- let l:branchname = GitBranch()
- return strlen(l:branchname) > 0?' '.l:branchname.' ':''
- endfunction
- set statusline=
- " set statusline+=%#CursorColumn#
- " set statusline+=%1* "switch to User1 highlight
- set statusline+=%#LineNr#
- set statusline+=\ %f
- set statusline+=%{StatuslineGit()}
- " set statusline+=%m\
- set statusline+=%=
- " set statusline+=\ %y
- set statusline+=%y
- set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
- set statusline+=\[%{&fileformat}\]
- set statusline+=\ %p%%
- set statusline+=\ %l:%c
- set statusline+=\
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement