Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
176 lines (141 sloc) 4.4 KB
""" B I N D I N G S
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Map jj to escape
inoremap jj <Esc>
" Map H, L to nav tabs
map L gt
map H gT
" Fast saving
nmap <leader>w :w!<cr>
" Switch to sudoer within the vim file
cmap w!! w !sudo tee % >/dev/null
" Fast editing of the .vimrc
map <leader>v :e! ~/.vim/vimrc<cr>
" Bash like keys for the command line
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-K> <C-U>
cnoremap <C-P> <Up>
cnoremap <C-N> <Down>
" Set to auto read when a file is changed from the outside
set autoread
" Remap VIM 0
map 0 ^
" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
if MySys() == "mac"
map nmap <D-j> <M-j>
map nmap <D-k> <M-k>
map vmap <D-j> <M-j>
map vmap <D-k> <M-k>
" Insert blank line in normal mode
" map <Enter> o<ESC>
" map <S-Enter> O<ESC>
" Do :help cope if you are unsure what cope is. It's super useful!
map <leader>cc :botright cope<cr>
map <leader>n :cn<cr>
" map <leader>p :cp<cr>
" => Moving around, tabs and buffers
" Map space to / (search) and c-space to ? (backgwards search)
map <space> /
map <c-space> ?
" Clear highlight of last search
map <silent> <leader>/ :noh<cr>
" Smart way to move btw. windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Close the current buffer
map <leader>bd :Bclose<cr>
" Close all the buffers
map <leader>ba :1,300 bd<cr>:q<cr>
" Use the arrows to something usefull
map <right> :bn<cr>
map <left> :bp<cr>
" Tab configuration
map <leader>tn :tabnew<cr>
map <leader>te :tabedit
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
" When pressing <leader>cd switch to the directory of the open buffer
" map <leader>cd :cd %:p:h<cr>
" => Visual mode related
" Really useful!
" In visual mode when you press * or # to search for the current selection
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>
" When you press gv you vimgrep after the selected text
vnoremap <silent> gv :call VisualSearch('gv')<CR>
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
" => Parenthesis/bracket expanding
"vnoremap ( <esc>`>a)<esc>`<i(<esc>
"vnoremap [ <esc>`>a]<esc>`<i[<esc>
"vnoremap { <esc>`>a}<esc>`<i{<esc>
"vnoremap "" <esc>`>a"<esc>`<i"<esc>
"vnoremap '' <esc>`>a'<esc>`<i'<esc>
" Map auto complete of (, ", ', [
inoremap (( ()<esc>i
inoremap << <><esc>i
inoremap [[ []<esc>i
inoremap {{ {<esc>o}<esc>O
inoremap '' ''<esc>i
inoremap "" ""<esc>i
" Smart mappings on the command line
cno $h e ~/
cno $d e ~/Desktop/
cno $j e ./
cno $c e <C-\>eCurrentFileDir("e")<cr>
" $q is super useful when browsing on the command line
cno $q <C-\>eDeleteTillSlash()<cr>
" about file openings
map <leader>et :tabe %%
map <leader>ev :vsp %%
map <leader>es :sp %%
map <leader>ew :e %%
map <leader>md :!mkdir -p %:p:h<CR>
" map <leader>cd :lcd %:h<CR>
"toggles wrap
nmap <leader>tw :set invwrap<CR>:set wrap?<CR>
" toggle highlight search
nmap <leader>hs :set hlsearch! hlsearch?<CR>
" adjust viewports to the same size
map <leader>= <C-W>=
" uppercase / lowercase convert
nmap <leader>L mQgewvu`Q
nmap <leader>U mQgewvU`Q
nmap <leader>l mQviwu`Q
nmap <leader>u mQviwU`Q
" Remap <Down> and <Up> to gj and gk
map <Up> gk
map <Down> gj
" use <F4> to toggle paste mode
nmap <F4> :set invpaste<CR>:set paste?<CR>
" shortcuts for diffget, diffput and diffupdate
map <leader>dfp :diffput<cr>
map <leader>dfg :diffget<cr>
map <leader>dfu :diffupdate<cr>
" toggle QuickFix List
map <silent> <leader>m :QFix<cr>
" FIXME: not working properly
" E486: Pattern not found: .
" E492: Not an editor command: $)<CR>
" underlines the current line with =
" nmap <leader>ul :t.|s/./=/g|:nohls<CR>
" finds the next conflict marker (tested with Git conflicted files)
" nmap <leader>fc <Esc>/\v^[<=>]{7}( .*|$)<CR>