vim 映射长 GNU 屏幕命令
您好,我在 stackoverflow 上看到了这个问题,但我的问题略有不同。
当我使用下面的地图时,我定义了一个方便的地图:
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>
这变成了一条很长的线,我更愿意将其按线分割。 我尝试过:
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>
但它不起作用。
关于如何将这个初始映射分割成几行有什么想法吗?
编辑:我实施的最终解决方案:
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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
之外,我在这里没有看到太多问题
:据我所知,这些是:map
的字符,而不是屏幕内的程序,因此您可以删除两个^V
。stuff
后面的空格。但有一些小问题:
nore
,请不要使用:map
。在这种情况下,您需要:nnoremap
,但:map
的nore
版本是:noremap
。非 nore 命令是不好的,因为随着映射数量的增加,新映射可能会破坏旧映射,而使用 nore 命令无法做到这一点。cat
正常查看,并且可以被各种实用程序视为二进制文件),因此使用\r
或\
,其中包含^M
(为此,您也可以使用\n
)。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 omittingnore
. In this case you need:nnoremap
, butnore
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 withnore
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
).