VIM

From UVOO Tech Wiki
Revision as of 17:01, 7 March 2019 by imported>Jeremy-busk
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

VIM Editor

Quick Commands

  • %s;^(\s+);\=repeat(' ', len(submatch(0))/2);g

Very Basic VIM setup

nano ~/.vimrc

colorscheme desert
"colorscheme wombat256
syntax on


filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab

" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab

" set default filetype if no extension, usually sh or py
au BufNewFile,BufRead * if &syntax == '' | set syntax=py | endif
filetype plugin on
au BufNewFile,BufRead * if &ft == '' | set ft=py | endif

"fix copy/paste issues with mouse
:set mouse=v

NGINX highlight

mkdir -p ~/.vim/syntax/
wget http://www.vim.org/scripts/download_script.php?src_id=19394 -O ~/.vim/syntax/nginx.vim

# Set location of Nginx config file
cat > ~/.vim/filetype.vim <<EOF
au BufRead,BufNewFile /etc/nginx/*,/etc/nginx/conf.d/*,/usr/local/nginx/conf/*,*/conf/nginx.conf if &ft == '' | setfiletype nginx | endif
EOF

https://github.com/nvie/vim-flake8