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
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " 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 '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
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Other shortcuts
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " Open NERDTree with Ctrl-n
- " TODO: auto reload tree
- map <C-n> :NERDTreeToggle<CR>
- " 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>
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
- " 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