Difference between revisions of "VIM"

From UVOO Tech Wiki
Jump to navigation Jump to search
 
(3 intermediate revisions by the same user not shown)
Line 40: Line 40:
 
au BufReadPost *.sls set syntax=yaml
 
au BufReadPost *.sls set syntax=yaml
 
set expandtab shiftwidth=2 softtabstop=2 smarttab
 
set expandtab shiftwidth=2 softtabstop=2 smarttab
 +
set paste
 +
set ruler
 +
" set number
 
```
 
```
  

Latest revision as of 22:29, 19 July 2022

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
au BufReadPost *.sls set syntax=yaml
set expandtab shiftwidth=2 softtabstop=2 smarttab
set paste
set ruler
" set number

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

One liners

g/^\s*$/d  # Delete blank lines
:set ts=2 sts=2 noet
:retab!

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