Permalink
Browse files

Create cmap for pasting escaped registers.

  • Loading branch information...
1 parent a046b17 commit 5e193a94f52aafde2e49c5d90cf197d11118b781 @nelstrom committed Sep 13, 2011
Showing with 15 additions and 0 deletions.
  1. +15 −0 vimrc
View
15 vimrc
@@ -195,6 +195,21 @@ map <leader>er :e <C-R>=expand("%:r")."."<CR>
nmap gV `[v`]
" http://stackoverflow.com/questions/6228079/remove-newlines-from-a-register-in-vim/6235707#6235707
nnoremap <expr> gV "`[".getregtype(v:register)[0]."`]"
+" <c-x>{char} - paste register into search field {{{2
+" escaping sensitive chars
+" http://stackoverflow.com/questions/7400743/
+cnoremap <c-x> <c-r>=<SID>PasteEscaped()<cr>
+function! s:PasteEscaped()
+ echo "\\".getcmdline()."\""
+ let char = getchar()
+ if char == "\<esc>"
+ return ''
+ else
+ let register_content = getreg(nr2char(char))
+ let escaped_register = escape(register_content, '\'.getcmdtype())
+ return substitute(escaped_register, '\n', '\\n', 'g')
+ endif
+endfunction
" Substitute command repetition {{{2
nnoremap & :~&<Enter>
vnoremap & :~&<Enter>

0 comments on commit 5e193a9

Please sign in to comment.