Wednesday, July 10, 2019

Re: execute an alias with vim

On Wed, Jul 10, 2019 at 10:30 AM Mathieu Roux <mthrx72@gmail.com> wrote:
>
> Hello,
>
> I use many text files to write many things on my laptop, and i use
> aliases to access them.
> For exemple, suppose that i have the alias "foo" to access ~/bar with
> vim.
>
> alias foo='vim ~/bar'
>
> So it works when i write "foo" in my terminal.
>
> But I also want to use this alias in vim.
> When i am in vim, i do "C-w n" to open one new window.
> And then i try :!foo
>
> But it writes:
>
> "/bin/bash: foo: command not found
>
> le shell a retourné 127"
>
> Can you help me?
> Best regards,
> Mathieu

When called from Vim to run an external :!command, the shell does not
source all the same startup files. I also have noticed that, for
instance, :!ll doesn't work in Vim (in a "normal" bash shell on my
system, ll is aliased to ls -l) so I have to use ls -l instead.

I think bash-from-Vim doesn't regard itself as an interactive shell
when used to run a :!command. If I type ":shell" (without the quotes)
in Vim, then ll gives me a long directory list.

Rather than call vim inside vim through the shell, why don't you do

:new ~/bar

? That would open the file ~/bar in a split-window in the same Vim.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXvASJ_HvUGoXFcDHPvq%2BhpPjnBd%3DrDTQcSqmdRcGqR7ow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments: