Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
Add easier window movement / creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Hodgson committed Apr 27, 2018
1 parent 3158f31 commit 702903b
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions .vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,32 @@ endfunction

" Find a file and pass it to cmd
function! DmenuOpen(cmd)
let fname = Chomp(system("git ls-files | rofi -dmenu -i -l 20 -p " . a:cmd))
if empty(fname)
return
endif
execute a:cmd . " " . fname
let fname = Chomp(system("git ls-files | rofi -dmenu -i -l 20 -p " . a:cmd))
if empty(fname)
return
endif
execute a:cmd . " " . fname
endfunction

" Moves to open window, or focuses it
" https://www.reddit.com/r/vim/comments/8f80o3/awesome_way_to_navigate_windows_and_autocreate/
function! WinMove(key)
let t:curwin = winnr()
exec "wincmd ".a:key
if (t:curwin == winnr())
if (match(a:key,'[jk]'))
wincmd v
else
wincmd s
endif
exec "wincmd ".a:key
endif
endfunction

" Commands {{{1

"gets the wp salts
command WpSalts :r! curl https://api.wordpress.org/secret-key/1.1/salt 2> /dev/null
command! WpSalts :r! curl https://api.wordpress.org/secret-key/1.1/salt 2> /dev/null


" Mappings {{{1
Expand All @@ -331,6 +346,12 @@ noremap <ScrollWheelDown> <nop>
nnoremap <c-o> :call DmenuOpen("e")<cr>
" make ctrl + hjkl move + create windows
nnoremap <C-h> :call WinMove('h')<cr>
nnoremap <C-j> :call WinMove('j')<cr>
nnoremap <C-k> :call WinMove('k')<cr>
nnoremap <C-l> :call WinMove('l')<cr>
" Make Ctrl C and Ctrl V work on system buffer
" if in visual or insert mode respectively
vnoremap <C-c> "+y
Expand Down

0 comments on commit 702903b

Please sign in to comment.