Open given files / Call vim function with given strings using Terminal API (xargs for vim)
vargs [-0] [-s {separators (comma-separated)}] [-I {replstr}] [-t] [{vim terminal-api arguments (default: "drop")} ...]
vargs
sends given arguments to Vim using Terminal API.
If no arguments were given, "drop"
is specified implicitly (default).
See below about Vim Terminal API.
-0 Change separator to NUL character. This is same as "-s nul"
-I string
If this replacement string was given, replace arguments by this with each item
-s string
Change separators with these comma-separated values (available values are "space", "tab", "newline", "nul") (default "newline")
-t Print JSON command to standard error before printing with escape sequence (verbose print)
I wanted a way to quickly open selected file using file fuzzy finder UI, like gof.
I sent a pull request to gof that adds -t
option to open selected file using Vim Terminal API.
After that, I got an idea that creating generic command for Vim Terminal API.
Vim Terminal API is very handy to communicate from processes inside Vim terminal window to outer Vim.
Other Vim plugin examples using Terminal API:
- sync-term-cwd.vim
- Sync Vim current directory with current directory of bash/zsh
- tapi-reg.vim
- Access Vim clipboard from bash/zsh
Using peco
$ ls | peco | vargs
Using gof (recurse subdirectories)
$ gof | vargs
However, gof
already has -t
option to open in Vim ๐
$ gof -t
$ find . -path ./.git -prune -o -type f | vargs
More safe way...
$ find . -path ./.git -prune -o -type f -print0 | vargs -0
$ ls -d $GOPATH/src/github.com/*/* | peco | vargs
You may prefer project-guide.vim.