简体   繁体   English

vim shell key mapping执行shell命令

[英]vim shell key mapping to execute shell commands

i am using vimshell to execute commands inside vim 我正在使用vimshell在vim中执行命令

nnoremap <leader>vs :VimShellPop<CR>

with this key mapping i can open vim shell and execute commands like 'bundle install' and then type exit to exit VimShellPop window but i want set a key mapping 使用此键映射,我可以打开vim shell并执行'bundle install'等命令,然后键入exit退出VimShellPop窗口,但我想设置键映射

nnoremap <leader>bi :

to open up vimshellpop execute the bundle install command and exit once i get completed..is it possible in vimshell? 打开vimshellpop执行bundle install命令并在我完成后退出..是否可以在vimshell中?

The vimshell plugin provides an interactive shell inside a Vim buffer. vimshell插件在Vim缓冲区内提供了一个交互式shell。 Apparently, you don't need the interactivity (because you intend to immediately exit after issuing the shell command). 显然,您不需要交互性(因为您打算在发出shell命令后立即exit )。 For that, you don't need the plugin itself; 为此,您不需要插件本身; the built-in :! 内置:! command already allows you to launch external commands: 命令已经允许您启动外部命令:

:nnoremap <leader>bi :!bundle install<CR>

If you want to keep the output visible, you can read it into a scratch buffer: 如果要保持输出可见,可以将其读入暂存缓冲区:

:nnoremap <leader>bi :new<Bar>0r!bundle install<CR>

Having an interactive shell in Vim is one of Vim's stated non-goals (cp. :help design-not ), so the plugin has to jump through several hoops to make this possible. 在Vim中使用交互式shell是Vim声明的非目标之一(cp。:help :help design-not ),因此插件必须跳过几个环节才能实现这一目标。 Those hacks are causing these problems (of defining a proper mapping, as evidenced by the attempts in the question's comments); 那些黑客正在造成这些问题(定义正确的映射,正如问题评论中的尝试所证明的那样); lack of automation (like through mappings) is a limitation of this approach. 缺乏自动化(如通过映射)是这种方法的局限。

You may contact vimshell's author (via email or GitHub issue); 您可以联系vimshell的作者(通过电子邮件或GitHub问题); he's usually very open and responsive! 他通常非常开放和敏感! He's in the best position to make such mapping work. 他最有能力进行这种绘图工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM