I want to map a key to the system command
`tmux set-buffer $var`
where $var is the value of @0 register. How do i insert the @0 value into the map command
map <leader>t :!tmux set-buffer @0
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityYou can use :execute {expr1}
to execute a string from evaluation of {expr1}
as an Ex command.
:exec "!tmux set-buffer" getreg("0")
will first combine the string !tmux set-buffer
with the results of getreg("0")
, adding a space in between, and then execute the resulting command. Presumably you want this only in normal mode, so it is advisable to use nnoremap
instead of map
as well.
The mapping itself should be
nnoremap <leader>t :exec "!tmux set-buffer" getreg("0")<CR>