I've written a short vim function that allows me to edit the contents of vim registers:
fun! RegBuff()
let vimstuff = "/tmp/vimstuff"
if !isdirectory(vimstuff)
call mkdir(vimstuff)
endif
let reg = getchar()
let reg = nr2char(reg)
exec 'au BufWrite vimreg-* exec "normal gg0\"'.reg.'yy"'
exec '1new '.vimstuff.'/vimreg-'.reg
exec 'normal ggdG"'.reg.'P'
endfun
nnoremap <leader><F2> :call RegBuff()<CR>
If I do, for instance, qqi1234^[
to record insert 1234 into the q register, and then call my function :call RegBuff()
or <leader><F2>
, I get a nice little window at the top with the contents of the buffer. Cool. if I edit it to be i12345678^[
, save the file and exit, and then do @q
, it properly now enters insert mode and inserts 12345678. Also cool.
The problem is that I generally run vim in tmux, and for some reason after executing this macro it switches to the tmux pane below vim. This is as if the macro is additionally running <Ctrl>j
after the macro is run.
If I go back to the vim pane, and type "qp
to see whats in the q
register it looks totally normal, it just contains what I expect to be in there.
Why does there appear to be this extra key code sent after I call the macro?
set nofixendofline
in the function or setting it manually doesn't change the behavior. – Brian Albert Monroe Jul 7 '17 at 15:07:echomsg @q
to see what is in registerq
, including special characters. – piojo Feb 15 '19 at 3:09