Skip to content

Instantly share code, notes, and snippets.

@wooyey
Last active June 9, 2020 18:02
Show Gist options
  • Save wooyey/21d5038ece25b33a2ab0919fb6b311df to your computer and use it in GitHub Desktop.
Save wooyey/21d5038ece25b33a2ab0919fb6b311df to your computer and use it in GitHub Desktop.
VIM Config
" Python formatting
au BufNewFile, BufRead *.py
\ set tabstop=4 |
\ set softtabstop=4 |
\ set shiftwidth=4 |
\ set textwidth=79 |
\ set expandtab |
\ set autoindent |
\ set fileformat=unix
au BufNewFile, BufRead *.js, *.html, *.css
\ set tabstop=2
\ set softtabstop=2
\ set shiftwidth=2
au BufRead, BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
set encoding=utf-8
syntax on
" Auto setup
autocmd! bufwritepost .vimrc source %
let mapleader=","
" Using clipboard copy <F2>
set pastetoggle=<F2>
set clipboard=unnamedplus
" Adding system clipboards support ("*" primary - mouse middle button and "+" as ctrl-c )
noremap <Leader>y "*y
noremap <Leader>p "*p
noremap <Leader>Y "+y
noremap <Leader>P "+p
" CTRL+n to turn off searched phrase highlight
noremap <C-n> :nohl<CR>
vnoremap <C-n> :nohl<CR>
inoremap <C-n> :nohl<CR>
" Fast save file - CTRL+z
noremap <C-Z> :update<CR>
vnoremap <C-Z> <C-C>:update<CR>
inoremap <C-Z> <C-O>:update<CR>
" Using ,e and ,E to exit VIM
noremap <Leader>e :quit<CR>
noremap <Leader>E :qa!<CR>
" CTRL + h/j/k/l to move between windows
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
" Walking between tabs: ,n(previous) ,m(next)
map <Leader>n <esc>:tabprevious<CR>
map <Leader>m <esc>:tabnext<CR>
" block moving: "<" left and ">" right
vnoremap < <gv
vnoremap > >gv
" Filetype recognition and syntax highlighting
filetype off
filetype plugin indent on
set relativenumber
set number
set nowritebackup
set noswapfile
set nobackup
set hlsearch
set ignorecase
set smartcase
" Trailing white spaces
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" setlocal spell spelllang=en_us
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment