Minimal Verifiable Solution
|
is a vim character, and must be escaped.
noremap ~~ :!
\bash -c "git rev-parse --show-toplevel
\\| xargs -I {}
\ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q {}"<CR>
Note: the following will work as well
noremap ~~ :!
\bash -c "git rev-parse --show-toplevel \
\| xargs -I {}
\ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q {}"<CR>
And this will fail:
noremap ~~ :!
\bash -c "git rev-parse --show-toplevel \
\| xargs -I {} \
ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q {}"<CR>
This seems to be a bug.
Style Guide
The xargs -I {}
trick is an excellent way to maintain full control of the arguement, with lateral linux-distribution compatibility. The purpose of xargs
is primarily to maintain feed-forward semantics so that direction of control-flow does not hop back and forth for the downstream reader (probably yourself) unnecessarily, i.e:
grep 'foo' <(cat bar)
sed 's/foo/bar/' $(generate baz)
Further, xargs -I {}
is semantically equivalent to parallel --keep-order -I {}
. gnu-parallel
advertises compatibility with xargs
; however, in my experience, this is superficial only; -I {}
, however, removes the impedement.
Contextual Discussion
When writing BASH, it is preferable to use double quotes and reserve single quotes for nested languages such as awk
, sed
, grep
, perl
, etc. This reduces clutter, and maintains env variable substitution. The sub-languages often have a mechanism for nested environment variable substitution through the use of flag-arguments.
An example is awk
, which uses -v varname=${BASH_ENV_VARIABLE}
, or python
, which uses -E
to turn on environment variable substitution within the single quotes. All instructions for these sub languages, which can be used from within vim, are accessible via info
or man
. man
is available in all distributions I am aware of, and can be used as follows:
man <command-name>
# e.g.
man python
Further, vi
can be connected to the command line vi set -o vi
, and accessed on the fly by typing <esc>-v
. Context switching may be painful if you also switch to vimmish commands and system calls.