You can try either
nnoremap <silent> t :<C-u>silent !../tt <C-r>=shellescape(expand('<cword>'), 1)<CR><CR><C-l>
or
nnoremap <silent> t :<C-u>call system('../tt '.shellescape(expand('<cword>')))<CR>
or even
nnoremap <expr> <silent> t system('../tt '.shellescape(expand('<cword>')))[-1]
. Note some things:
- Don’t use
map (without n and nore) unless you have a specific reason. I believe you don’t need this mapping for visual and operator-pending modes (leading n restricts mapping to normal mode only) and you also should not want this mapping to be remappable.
- Use
<C-u> to discard count you can occasionally type unless you do know you need it (third version uses two hacks that turn mapping to no-op with a side-effect and does not need <C-u>).
- Never forget to escape shell arguments.
- Version with
silent ! (do not forget space after silent, this is why @David Pope’s answer does not work) has <C-l> at the end. This is because using ! will always provide access to your terminal and thus redraw is needed after command has run.
- Versions with
system() won’t work if you add an argument containing newline, it is a documented bug. If you don’t want to do so (expand('<cword>') won’t ever add newline) it is absolutely safe.
t is a very useful motion. It is better to learn to use it then remap it to something. I suggest ,t as a lhs.
$ ../t worddo? What's the output? Do you want to put it in the buffer?t? This is a useful movement command ...