简体   繁体   中英

Command substitution in command-line mode (ex mode) in Vim

Short and simple example

How can I use shell like command substitution in the vim command-line mode?

For example, if I want to edit a particular path whose path is available as output of another command, say, which foo , I could do something like this on the shell.

vim "$(which foo)"

How can I do this with the :e command when I am already within Vim?

I am looking for something that is the equivalent of :e $(which foo.txt) .

Real use case

The above is just a short example so that this question makes sense for everyone. Here is the real reason why I am looking for this answer.

In the shell, I can execute gdb -p $(pidof bar) to attach to a process bar and debug it. With Vim, I am using ConqueGdb which accepts the same arguments as gdb, so I would want to do something like :ConqueGdb -p $(pidof bar) from within Vim.

:e `which foo`
:help backtick-expansion

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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