Difference between revisions of "VIM"
Jump to navigation
Jump to search
(9 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
nano ~/.vimrc | nano ~/.vimrc | ||
``` | ``` | ||
− | colorscheme desert | + | " colorscheme desert |
"colorscheme wombat256 | "colorscheme wombat256 | ||
syntax on | syntax on | ||
Line 37: | Line 37: | ||
"fix copy/paste issues with mouse | "fix copy/paste issues with mouse | ||
− | + | set mouse=v | |
au BufReadPost *.sls set syntax=yaml | au BufReadPost *.sls set syntax=yaml | ||
+ | set expandtab shiftwidth=2 softtabstop=2 smarttab | ||
+ | set paste | ||
+ | set ruler | ||
+ | " set number | ||
``` | ``` | ||
Line 45: | Line 49: | ||
mkdir -p ~/.vim/syntax/ | mkdir -p ~/.vim/syntax/ | ||
wget http://www.vim.org/scripts/download_script.php?src_id=19394 -O ~/.vim/syntax/nginx.vim | 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 | 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 | au BufRead,BufNewFile /etc/nginx/*,/etc/nginx/conf.d/*,/usr/local/nginx/conf/*,*/conf/nginx.conf if &ft == '' | setfiletype nginx | endif | ||
Line 52: | Line 57: | ||
``` | ``` | ||
+ | # One liners | ||
+ | ``` | ||
+ | g/^\s*$/d # Delete blank lines | ||
+ | ``` | ||
+ | |||
+ | ``` | ||
+ | :set ts=2 sts=2 noet | ||
+ | :retab! | ||
+ | ``` | ||
https://github.com/nvie/vim-flake8 | https://github.com/nvie/vim-flake8 |
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!