Skip to content

Instantly share code, notes, and snippets.



Created Jun 23, 2016
What would you like to do?
set ts=4
set sw=4
set et
set ai
set hls
so ~/.vim/Align.vim
" To install vim plugins
execute pathogen#infect()
syntax on
filetype plugin indent on
" vim plugin to align
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
" only to work in insert mode
iab ic #include
iab id #define
iab ci cin>>;<Esc>i
iab co cout<<;<Esc>i
iab con cout<<endl;
iab cen cerr<<endl;
iab el <<endl;
iab pf printf("");<Esc>hhi
iab pfn printf("\n");
iab pfd printf("%d",);<Esc>hhhi
iab pfs printf("%s\n",);<Esc>hhhi
iab sf scanf("%", &);<Esc>hhhi
iab sfd scanf("%d", &);<Esc>hhhi
iab sfs scanf("%s", &);<Esc>hhhi
iab fori for(int i=0; i<n; i++)
iab forj for(int j=0; j<n; j++)
iab wi while(i<n)
iab ints int myInts[] = {75, 23, 65, 42, 13};
iab for9 for(int i=0; i<9; i++)
iab maps map<char, int> letter_counts {{'a', 27}, {'b', 3}, {'c', 1}};
iab fora for(auto it : p) {
iab veci vector<int> v;
iab vecit vector<int>::iterator vit;
iab mapi map<string, int> m;
iab mapit map<string, int>::iterator m;
iab seti set<int> m;
iab setit set<int>::iterator m;
iab 2dvec vector<vector<int>> v2(3, vector<int>(2,0)); // all initialized to 0
"iab fgets
" strip trailing space on save
autocmd BufWritePre * :%s/\s\+$//e
" auto-indent, expand-tab, shift-width, tab-stop
set et
set sw=4
set ts=4
" display status line 'laststatus'
" set ls=2
set ai
colorscheme desert
autocmd BufNewFile *.cpp -r ~/Dropbox/a/template.cpp
" autocmd BufNewFile *.cpp -r ~/Dropbox/a/
"set spell
" save and load folds
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent loadview
" Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_cpp_compiler_options = ' -DCODING -std=c++11'
let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_filetypes': [] }
nnoremap <C-w>E :SyntasticCheck<CR> :SyntasticToggleMode<CR>
set number numberwidth=5
set shiftround
" relative number
set rnu
set wrap
let mapleader="\\"
"let mapleader="<"
"toggle line number
"nnoremap <leader>l :set nonu! nornu!<cr>
nnoremap <F2> :set nonu! nornu! nu? <cr>
nnoremap ,ev :vsplit $MYVIMRC<cr>
nnoremap ,sv :source $MYVIMRC<cr>
" quickly open cpp template file
nnoremap ,et :vsplit $MYCPPTEMPLATE<cr>
nnoremap ,eb :vsplit $HOME/.bashrc<cr>
:autocmd FileType python nnoremap <buffer> <localleader>c I#<esc>
:autocmd FileType cpp nnoremap <buffer> <localleader>c I#<esc>
"inoremap jk <esc>
"inoremap <esc> <nop>
" nnoremap <F2>E :set number!<CR>
" Start NERDTree
" autocmd VimEnter * NERDTree
" Go to previous (last accessed) window.
autocmd VimEnter * wincmd p
" toggle nerdtree
map <C-n> :NERDTreeToggle<CR>
" close nerdtree if it's last buffer
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let NERDTreeShowBookmarks=1
set pastetoggle=<F10>
set swapfile
set dir=$HOME/.vim/swapfiles
" move between viewports
nnoremap <C-j> <C-W>j
nnoremap <C-k> <C-W>k
nnoremap <C-h> <C-W>h
nnoremap <C-l> <C-W>l
" nnoremap <leader>sw :w !sudo tee %<CR>
nnoremap <leader>ci :execute "vsplit"<CR><C-W>r<CR>;
" NerdCommenter
let g:NERDSpaceDelims = 1
let g:NERDCompactSexyComs = 1
"autocmd VimEnter * noremap <leader>cc <leader>ci
nmap <Leader>cc <Plug>NERDCommenterInvert
set title
set titleold=
" open input file
noremap <F3> :execute "split"<CR><C-W>r<CR>
" Execute
nnoremap <F4> :execute '!g++ --std=c++11 -Wall -g -DCODING ' . shellescape(join([expand("%:r"),"cpp"],"."),1).
\ ' && ./a.out < '. shellescape(join([expand("%:r"), "in"], "."), 1)<CR>
" verbose nnoremap <C-q> :execute 'q'<CR>
verbose nnoremap <C-q> :q<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment