Skip to content

Commit

Permalink
Merge pull request #11 from wellle/xtal8-master
Browse files Browse the repository at this point in the history
10 Don't remap existing mappings, add <Plug> mappings for easy remapping
  • Loading branch information
wellle authored Sep 23, 2016
2 parents 87eb85d + 7891efa commit 49b29a4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ is only one way of many:

### Mappings

Mappings will not overwrite your existing mappings.

For the most common use case of working on visual selections there are some
visual mode mappings provided:

Expand Down Expand Up @@ -92,8 +94,27 @@ pending mode. So this also works:
<C-W>gssip
```

## Installation
### Remapping
For easier remapping, `<Plug>` mappings are provided. Change the key sequences
below and put them into your vimrc:

Visual-mode:
```vim
xmap <C-W>gr <Plug>(Visual-Split-VSResize)
xmap <C-W>gss <Plug>(Visual-Split-VSSplit)
xmap <C-W>gsa <Plug>(Visual-Split-VSSplitAbove)
xmap <C-W>gsb <Plug>(Visual-Split-VSSplitBelow)
```

Operator-pending mode:
```vim
nmap <C-W>gr <Plug>(Visual-Split-Resize)
nmap <C-W>gss <Plug>(Visual-Split-Split)
nmap <C-W>gsa <Plug>(Visual-Split-SplitAbove)
nmap <C-W>gsb <Plug>(Visual-Split-SplitBelow)
```

## Installation
Use your favorite plugin manager.

- [NeoBundle](https://github.com/Shougo/neobundle.vim)
Expand Down
28 changes: 20 additions & 8 deletions plugin/visual-split.vim
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
" provide <Plug> mappings for easy remapping
nnoremap <silent> <Plug>(Visual-Split-Resize) :<C-u>set operatorfunc=<SID>opgr<CR>g@
nnoremap <silent> <Plug>(Visual-Split-Split) :<C-u>set operatorfunc=<SID>opgss<CR>g@
nnoremap <silent> <Plug>(Visual-Split-SplitAbove) :<C-u>set operatorfunc=<SID>opgsa<CR>g@
nnoremap <silent> <Plug>(Visual-Split-SplitBelow) :<C-u>set operatorfunc=<SID>opgsb<CR>g@
" normal mode mappings set operator functions
" TODO: make these silent?
nnoremap <silent> <C-W>gr :<C-u>set operatorfunc=<SID>opgr<CR>g@
nnoremap <silent> <C-W>gss :<C-u>set operatorfunc=<SID>opgss<CR>g@
nnoremap <silent> <C-W>gsa :<C-u>set operatorfunc=<SID>opgsa<CR>g@
nnoremap <silent> <C-W>gsb :<C-u>set operatorfunc=<SID>opgsb<CR>g@
silent! nmap <unique> <C-W>gr <Plug>(Visual-Split-Resize)
silent! nmap <unique> <C-W>gss <Plug>(Visual-Split-Split)
silent! nmap <unique> <C-W>gsa <Plug>(Visual-Split-SplitAbove)
silent! nmap <unique> <C-W>gsb <Plug>(Visual-Split-SplitBelow)
" operator functions trigger visual mappings
function! s:opgr(type, ...)
Expand All @@ -27,11 +33,17 @@ function! s:op(trigger)
silent execute "normal \<C-W>" . a:trigger
endfunction

" provide <Plug> mappings for easy remapping
xnoremap <silent> <Plug>(Visual-Split-VSResize) :VSResize<CR>
xnoremap <silent> <Plug>(Visual-Split-VSSplit) :VSSplit<CR>
xnoremap <silent> <Plug>(Visual-Split-VSSplitAbove) :VSSplitAbove<CR>
xnoremap <silent> <Plug>(Visual-Split-VSSplitBelow) :VSSplitBelow<CR>
" visual mappings execute commands
xnoremap <silent> <C-W>gr :VSResize<CR>
xnoremap <silent> <C-W>gss :VSSplit<CR>
xnoremap <silent> <C-W>gsa :VSSplitAbove<CR>
xnoremap <silent> <C-W>gsb :VSSplitBelow<CR>
silent! xmap <unique> <C-W>gr <Plug>(Visual-Split-VSResize)
silent! xmap <unique> <C-W>gss <Plug>(Visual-Split-VSSplit)
silent! xmap <unique> <C-W>gsa <Plug>(Visual-Split-VSSplitAbove)
silent! xmap <unique> <C-W>gsb <Plug>(Visual-Split-VSSplitBelow)
" commands call functions
command! -range VSResize call <SID>resize(<line1>, <line2>)
Expand Down

0 comments on commit 49b29a4

Please sign in to comment.