From e55a564b34741234c6c8ed9daed8f06d96ce6dc3 Mon Sep 17 00:00:00 2001 From: viktorbarzin Date: Wed, 6 Feb 2019 15:42:21 +0000 Subject: [PATCH] add new vim features --- .vimrc | 122 ++++++++++++++++----------------------------------------- 1 file changed, 33 insertions(+), 89 deletions(-) diff --git a/.vimrc b/.vimrc index bf6cbf3..9cb3f76 100644 --- a/.vimrc +++ b/.vimrc @@ -47,10 +47,12 @@ set statusline+=%* " Disables syntastic popup window with messages " Set both to 1 to turn it on -let g:syntastic_always_populate_loc_list = 0 -let g:syntastic_auto_loc_list = 0 -let g:syntastic_check_on_open = 0 -let g:syntastic_python_checkers = ['flake8'] +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 +" 3 errors is more than enough +let g:syntastic_loc_list_height=3 nnoremap :SyntasticCheck mypy " Set xptemplate trigger key to tab @@ -93,6 +95,9 @@ inoremap jk " Easier buffer closing nnoremap q :bd +" Close splits instead of buffers +" nnoremap q :q + " Swap to previous buffer nnoremap :b# @@ -100,16 +105,17 @@ nnoremap :b# nnoremap h vnoremap d -" Save with s +" Save with s in normal and insert mode noremap s :update +inoremap s :update " Sudo save with S noremap S :w !sudo tee % > /dev/null +" map sort function to a key +vnoremap s :sort " Writes to all buffers when switching to another buffer set autowrite -" Enable virtualenv -let g:airline#extensions#virtualenv#enabled = 1 " Enable tabs plugin let g:airline#extensions#tabline#enabled = 1 let g:airline#extensions#tabline#left_sep = ' ' @@ -140,26 +146,6 @@ if has("autocmd") au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif endif -" Set comment string for commentary.vim for python -set commentstring=#%s - -" I no longer use that because emmet.vim does all I need -""Auto complete HTLM tags -"function! s:CompleteTags() -" inoremap > >:startinsert!? -" inoremap > > -" inoremap > >:startinsert!?$ -"endfunction - -"autocmd BufRead,BufNewFile *.html,*.js,*.xml call s:CompleteTags() - -" Sources $MYVIMRC on changes -" augroup reload_vimrc " { -" autocmd! -" autocmd BufWritePost $MYVIMRC source $MYVIMRC -" augroup END " } - - " Set VIMHOME if has('win32') || has ('win64') let $VIMHOME = $VIM."/vimfiles" @@ -167,7 +153,6 @@ if has('win32') || has ('win64') let $VIMHOME = $HOME."/.vim" endif - " Bind nohl " Removes highlight of your last search " ```` stands for ``CTRL`` and therefore ```` stands for ``CTRL+n`` @@ -182,18 +167,15 @@ noremap :b# vnoremap :b# "inoremap :b# - " Quicksave command " noremap :update " vnoremap :update " inoremap :update -" Execute current file with python -noremap e :!python % - " bind Ctrl+ keys to move around the windows, instead of using " Ctrl+w + " Every unnecessary keystroke that can be saved is good for your health :) +"nmap :wincmd j map j map k map l @@ -206,13 +188,9 @@ map n ;bp " Create empty buffer and open it map t :enew - -" map sort function to a key -vnoremap s :sort - " easier moving of code blocks " Try to go into visual mode (v), thenselect several lines of code here and -" then press ``>`` several times. +" then press `>` several times. vnoremap < >gv " better indentation @@ -241,35 +219,12 @@ filetype off filetype plugin indent on syntax on -" Ignore flake8 E501 for lines longer than 80 characters -" E128 - visual continuation -" W391 - blank line at end of file -" let g:syntastic_python_flake8_args='--ignore=W391, E501, E701, E702' -" let g:syntastic_python_flake8_show_quickfix=1 -" let g:pymode_lint_ignore="E501,W601,W391,W0401,E702,E701" -let g:pymode_lint_ignore=["E501","W601","W391","W0401","E702","E701"] -let g:pymode_lint_settingscwindow = 1 -let g:pymode_rope = 1 -" let g:pymode_rope_autoimport = 0 -let g:pymode_rope_regenerate_on_write = 0 -let g:pymode_python="python3" -let g:pymode_lint_checkers = ['pep8'] -let g:pymode_breakpoint_cmd = 'import ipdb; ipdb.set_trace() # XXX BREAKPOINT' -let g:pymode_rope_completion = 1 - -" Run Lint fixer on save -nnoremap p :PymodeLintAuto -nnoremap zz :folddoclosed if foldlevel('.') < foldlevel(line('.')+1) \| exe 'norm! zo' \| endif - -" Make quickfix screen smaller -let g:syntastic_loc_list_height=1 - " In visual mode searches for the selected word vnoremap // y/" " Showing line numbers and length " set tw=79 " width of document (used by gd) -set tw=120 " width of document (used by gd) +" set tw=120 " width of document (used by gd) set nowrap " don't automatically wrap on load set fo-=t " don't automatically wrap text when typing set colorcolumn=120 @@ -306,7 +261,6 @@ set directory=~/.vim/tmp//,. set dir=~/.vim/tmp//,. set undodir=~/.vim/tmp/undo// - " Setup Pathogen to manage your plugins " mkdir -p ~/.vim/autoload ~/.vim/bundle " curl -so ~/.vim/autoload/pathogen.vim @@ -319,19 +273,11 @@ set nocp call pathogen#infect() -" -"============================================================================ -" Python IDE Setup -" -"============================================================================ - - " Settings for vim-powerline " cd ~/.vim/bundle " git clone git://github.com/Lokaltog/vim-powerline.git set laststatus=2 - " Settings for ctrlp " cd ~/.vim/bundle " git clone https://github.com/kien/ctrlp.vim.git @@ -341,7 +287,6 @@ set wildignore+=*.pyc set wildignore+=*_build/* set wildignore+=*/coverage/* - " Settings for python-mode " Note: I'm no longer using this. Leave this commented out " and uncomment the part about jedi-vim instead @@ -407,21 +352,12 @@ function! OmniPopup(action) return a:action endfunction -"inoremap =OmniPopup('j') -"inoremap =OmniPopup('k') -set omnifunc=jedi#completions -:"py3 import sys; sys.path[2]='/root/.virtualenvs/django/bin/python' -" set omnifunc=syntaxcomplete#Complete - " Python folding " mkdir -p ~/.vim/ftplugin " wget -O ~/.vim/ftplugin/python_editing.vim "http://www.vim.org/scripts/download_script.php?src_id=5492 set foldenable -" Auto activate virtual enviorment -let g:virtualenv_auto_activate = 1 - " Keep undo history even after closing file set undofile @@ -439,13 +375,13 @@ endif " au! BufRead,BufNewFile *.sh,*.tcl,*.php,*.pl let Comment="#" " if the comment character for a given filetype happens to be @ " then use let Comment="\@" to avoid problems... -function! CommentLines() - "let Comment="#" " shell, tcl, php, perl - exe ":s@^@".g:Comment."@g" - exe ":s@$@".g:EndComment."@g" -endfunction -" map visual mode keycombo 'co' to this function -vmap co :call CommentLines() +" function! CommentLines() +" "let Comment="#" " shell, tcl, php, perl +" exe ":s@^@".g:Comment."@g" +" exe ":s@$@".g:EndComment."@g" +" endfunction +" " map visual mode keycombo 'co' to this function +" vmap co :call CommentLines() " Encryption algo (vim -x file) set cm=blowfish2 @@ -471,13 +407,13 @@ set matchtime=3 " Fold functions in bash let g:sh_fold_enabled=3 - " Recompute syntax highlighting nnoremap :syntax sync fromstart autocmd FileType markdown syntax sync fromstart set cursorline +" Minimal number of lines before scrolling set scrolloff=3 set sidescrolloff=3 @@ -488,8 +424,16 @@ endif set relativenumber -nnoremap Q :qa +" nnoremap Q :qa " Remap ; to be : - save 1 key press :P nnoremap ; : nnoremap : ; + +" Gundo docs https://sjl.bitbucket.io/gundo.vim/ +nnoremap :GundoToggle + +" Auto encrypt files related to courseworks at uni +augroup encrypted + autocmd BufNewFile */soton/*/coursework* :X +augroup END