Skip to content

Commit

Permalink
Make mapping configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
ku1ik committed Jul 29, 2012
1 parent 736e2df commit ff6b156
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ To white-list some filetypes put following in your .vimrc:

*Note: if white list is defined no black list checking is performed.*

If you don't want pasta to override default `p` and `P` mappings you can
change it like this:

let g:pasta_paste_before_mapping = ',P'
let g:pasta_paste_after_mapping = ',p'

## Author

Marcin Kulik (@sickill)
9 changes: 9 additions & 0 deletions doc/pasta.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Basically it opens new, properly indented line (with |o| or |O|) in the place
you're pasting to then it pastes the text with |]p|. The result is nicely
indented code with relative indentation between pasted lines preserved.

See configuration section below for details on how to use different mapping
than |p| and |P|.

CONFIGURATION *pasta-config*

By default pasta is disabled for python, coffeescript and markdown because
Expand All @@ -32,6 +35,12 @@ To white-list some filetypes put following in your .vimrc: >
Note: if white list is defined no black list checking is performed.

If you don't want pasta to override default |p| and |P| mappings you can
change it like this: >
let g:pasta_paste_before_mapping = ',P'
let g:pasta_paste_after_mapping = ',p'
ABOUT *pasta-about*

Grab the latest version or report a bug on GitHub:
Expand Down
20 changes: 12 additions & 8 deletions plugin/pasta.vim
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,25 @@ function! s:SetupPasta()
return
endif

if maparg('p') ==# ''
nmap <buffer> p <Plug>AfterPasta
xmap <buffer> p <Plug>VisualPasta
endif
exe "nmap <buffer> " . g:pasta_paste_before_mapping . " <Plug>BeforePasta"
exe "xmap <buffer> " . g:pasta_paste_before_mapping . " <Plug>VisualPasta"

if maparg('P') ==# ''
nmap <buffer> P <Plug>BeforePasta
xmap <buffer> P <Plug>VisualPasta
endif
exe "nmap <buffer> " . g:pasta_paste_after_mapping . " <Plug>AfterPasta"
exe "xmap <buffer> " . g:pasta_paste_after_mapping . " <Plug>VisualPasta"
endfunction

if !exists("g:pasta_disabled_filetypes")
let g:pasta_disabled_filetypes = ["python", "coffee", "markdown"]
endif

if !exists("g:pasta_paste_before_mapping")
let g:pasta_paste_before_mapping = 'P'
endif

if !exists("g:pasta_paste_after_mapping")
let g:pasta_paste_after_mapping = 'p'
endif

nnoremap <silent> <Plug>BeforePasta :<C-U>call <SID>NormalPasta('P', 'O')<CR>
nnoremap <silent> <Plug>AfterPasta :<C-U>call <SID>NormalPasta('p', 'o')<CR>
xnoremap <silent> <Plug>VisualPasta :<C-U>call <SID>VisualPasta()<CR>
Expand Down

0 comments on commit ff6b156

Please sign in to comment.