Browse files

Create register-escapement plugin

  • Loading branch information...
1 parent 4a9378c commit b1b8dea6195831c7016ca5e3797aed2a3d61e1e5 @nelstrom committed Jan 21, 2012
Showing with 15 additions and 15 deletions.
  1. +14 −0 vim/plugin/register-escapement.vim
  2. +1 −15 vimrc
View
14 vim/plugin/register-escapement.vim
@@ -0,0 +1,14 @@
+" <c-x>{char} - paste register into search field, 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
View
16 vimrc
@@ -151,21 +151,7 @@ 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>
xnoremap & :&&<Enter>

0 comments on commit b1b8dea

Please sign in to comment.