skeept
skeept

Reputation: 12413

vim map long GNU Screen command

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

Answers (1)

ZyX
ZyX

Reputation: 53614

I do not see much problems here except

  1. The <C-v>: AFAIK these are characters for :map, not for program inside screen and thus you can remove two ^V.
  2. You forgot space after stuff.

There are some minor issues though:

  1. Do not use :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.
  2. Having raw control characters in the text file is bad (they then can’t be normally viewed by 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

Related Questions