keymaps: Smart vsplit direction for fsswitch
[vimconf.git] / keymaps.vim
index 9f9f6aa1f6c534dd13bb480e3446eadca8b81ce9..bc6f51d547110ee3010ff132ad78b7bc56ef0887 100644 (file)
@@ -1,6 +1,15 @@
 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 " Global settings
 
+if has('clipboard')
+    " Ordinary ctrl+{c,x,v} using system clipboard register +. We use autocmd to
+    " override plugin keymaps.
+    autocmd VimEnter * vnoremap <C-c> "+y
+    autocmd VimEnter * vnoremap <C-x> "+x
+    autocmd VimEnter * nnoremap <C-v> "+p
+    autocmd VimEnter * inoremap <C-v> <c-r>+
+endif
+
 nnoremap <C-p> :Denite file/rec<cr>
 nnoremap <space>/ :Denite grep:.<cr>
 nnoremap <space>s :Denite buffer<cr>
@@ -30,8 +39,23 @@ nmap ga <Plug>(EasyAlign)
 
 au Filetype gnuplot map <buffer> <F5> :call OpenIn("gnuplot -persist") <CR>
 
-au Filetype c,cpp,objc map <buffer> <F11> :vsplit<CR>:FSRight<CR>
+" Performs a vertial split and a FSHere. For a header file the split is
+" performed to the left, for an implementation file to the right.
+function FSvsplit()
+    " We split to the right on header files
+    if match(expand('%:e'), 'h.*') >= 0
+        execute ':leftabove vsplit'
+    else
+        execute ':rightbelow vsplit'
+    endif
+
+    execute ':FSHere'
+endfunction
+
+au Filetype c,cpp,objc map <buffer> <F11> :call FSvsplit()<CR>
+" Terminal-based vi report S-F11 as F23
 au Filetype c,cpp,objc map <buffer> <S-F11> :FSHere<CR>
+au Filetype c,cpp,objc map <buffer> <F23> :FSHere<CR>
 
 au Filetype markdown map <buffer> <F5> :call RunMarkdown()<CR>
 au Filetype asciidoc map <buffer> <F5> :call RunAsciidoc()<CR>
@@ -54,8 +78,6 @@ au FileType java imap <F7> <Plug>(JavaComplete-Imports-RemoveUnused)
 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
 " Some plugin-specific settings
 
-" Add :imap to :map of plugin
-imap <C-l> <Plug>Unicoder
 
 
 if filereadable($HOME . '/.vim/keymaps-local.vim')