Skip to content

Instantly share code, notes, and snippets.

@aburok
Last active September 20, 2016 04:45
Show Gist options
  • Save aburok/cb97dd1a0dab3eb5c945 to your computer and use it in GitHub Desktop.
Save aburok/cb97dd1a0dab3eb5c945 to your computer and use it in GitHub Desktop.
Vim common configuration for GVim and VsVim
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
" Vim ESCAPE Combinations{{{
imap jj <esc>
imap <S-Space> <Esc>
vnoremap <S-Space> <Esc>
" }}}
nnoremap <Space> /
map 0 ^
map Q <nop>
" map space in normal mode to Search :)
"inoremap <S-space> <esc>
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set number " Show line numbers
set ruler " Show position in file
set history=100
" show matching bracket
set showmatch
set incsearch
set hlsearch
" Pressing * will select a word and serch for it in a file
set ignorecase
set wildmenu " show list instead of just completing
set wildmode=list:longest,full
set ai " Auto indent
set si " Smart indent
set wrap " Wrap lines
" Disable inserting new line characters in long lines
set textwidth=0 wrapmargin=0
set cursorline
set autoread
let g:mapleader = ','
let mapleader = ','
nmap - $
xmap - $
nmap <enter> i<cr><esc>
nnoremap <Leader>o mto<Esc>`t
nnoremap <Leader>O mtO<Esc>`t
nnoremap zj :join<CR>
" WINDOWS BINDINGS
" backspace in Visual mode deletes selection
vnoremap <BS> X
" CTRL-X and SHIFT-Del are Cut
vnoremap <C-X> "+x
vnoremap <S-Del> "+x
" CTRL-C and CTRL-Insert are Copy
vnoremap <C-C> "+y
vnoremap <C-Insert> "+y
" CTRL-V and SHIFT-Insert are Paste
map <C-V> "+gp
map <S-Insert> "+gp
cmap <C-V> <C-R>+
cmap <S-Insert> <C-R>+
" nnoremap p i<C-R>0<Esc> - DELETED - to much confusion with default behavior
" CTRL-A is Select all
noremap <C-A> gggH<C-O>G
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G
onoremap <C-A> <C-C>gggH<C-O>G
snoremap <C-A> <C-C>gggH<C-O>G
xnoremap <C-A> <C-C>ggVG
" CTRL-S is Save File
imap <C-S> <Esc>:w!<cr>a
" after going to next find , center the screen on the finding "
map N Nzz
map n nzz
" Close window"
"============="
nnoremap zx :wq<CR>
"Find and Replace Text
vnoremap <C-R> "hy:%s/<C-R>h//gc<left><left><left>
vnoremap <F3> "hy:%s/<C-R>h//gc<left><left><left>
nmap <leader>sc :set nohlsearch<CR>
\Yp
\V:s/[^\"\n]/=/g<CR>
\kP
\V:s/[^\"\n]/=/g<CR>
\:let @/=""<CR>
\:set hlsearch<CR>
" Pasting & replacing from 0 yank register
nnoremap <Leader>p "0p
nnoremap <Leader>r viW"0p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment