Rajanand02
Rajanand02

Reputation: 1303

vim shell key mapping to execute shell commands

i am using vimshell to execute commands inside 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

nnoremap <leader>bi :

to open up vimshellpop execute the bundle install command and exit once i get completed..is it possible in vimshell?

Upvotes: 5

Views: 3222

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172608

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. 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); he's usually very open and responsive! He's in the best position to make such mapping work.

Upvotes: 1

Ingo Karkat
Ingo Karkat

Reputation: 172608

The vimshell plugin provides an interactive shell inside a Vim buffer. Apparently, you don't need the interactivity (because you intend to immediately exit after issuing the shell command). 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>

Upvotes: 5

Related Questions