0

I have this bit of vim script:

nmap <F9> :w<cr>
  \:execute 'silent !tmux new -ds blah'<cr>
  \:execute "silent !tmux send-keys -t blah '%:p' Enter"<cr>
  \:execute 'silent !open_iterm'<cr>
  \:redraw!<cr>

It chokes when there is a space in the path with a "no such directory" error. the culprit is the %:p bit. How do I fix this?

  • 1
    You should use nnoremap instead of nmap here, see :help :nore and :help map for the relevant help texts. – Karl Yngve Lervåg Jan 18 at 8:01
0

Got it:

nmap <F9> :w<cr>
  \:execute 'silent !tmux new -ds blah'<cr>
  \:execute "silent !tmux send-keys -t blah '" . fnameescape(expand('%:p')) . "' Enter"<cr>
  \:execute 'silent !open_iterm'<cr>
  \:redraw!<cr>`
  • The second command is doubling the quotes -- first single quotes in the command and then whatever fnameescape() decides to do for escaping -- which may cause problems. – jamessan Jan 18 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.