Reputation: 12413
Hi I have seen this question here on stackoverflow, but my question is slightly different.
When I use the following map I define a convenient map:
map <Leader>r :!screen -p run_and_test -X stuff '(cd /really/long/folder/data/gen_prob; epy gen_data.py)^V^V^M'<CR><CR>
This becames in a really long line, and I would prefer to split this by lines. I tried with:
let folder = '/really/long/folder/gen_prob'
let cmd = "'(cd " . folder . "; python gen_data.py)^V^V^M'"
map <Leader>r :execute "!screen -p run_and_test -X stuff" . cmd <cr><cr>
but it does not work.
Any idea on how to split this initial mapping over several lines?
edit: Final solution I implemented:
function! Execute_screen()
let folder = '/really/long/folder/gen_prob'
let cmd = "'(cd " . folder . "; python gen_data.py)\r'"
execute "!screen -p run_and_test -X stuff " . cmd
endfunction
noremap <Leader>r :call Execute_screen()<cr><cr>
Upvotes: 0
Views: 179
Reputation: 53614
I do not see much problems here except
<C-v>
: AFAIK these are characters for :map
, not for program inside screen and thus you can remove two ^V
.stuff
.There are some minor issues though:
:map
if you don’t know why you are omitting nore
. In this case you need :nnoremap
, but nore
version of :map
is :noremap
. Non-nore
commands are bad because as the number of mappings grows chances that new mapping will screw the old one grow and this won’t be done with nore
commands.cat
and can be treated as binary files by various utilities), so use \r
or \<C-m>
where you have ^M
(for this purpose you can also use \n
).Upvotes: 2