I have a bash command that will align text into a tabular form. If I have input such as this:
A | B | C
Alpha | Beta | Gamma
12 | 34.56 | 78.9
I can run cat test.txt | sed -e 's/|/'$'\001''|/g' | column -t -s $'\001'
to get:
A | B | C
Alpha | Beta | Gamma
12 | 34.56 | 78.9
The \001
is a delimiter I use with column
since I want to retain the |
in the text.
I can run this command inside vim by first visually selecting lines and then :'<,'>!sed ...
with command exactly as above, without the cat
.
I want to turn this into a vim map so that I can visually highlight a bunch of rows, or use text objects, and do the same alignment. Unfortunately, the following:
vnoremap <leader>t :'<,'>!sed -e 's/|/'$'\001''|/g' | column -t -s $'\001'
gives me the error E486: Pattern not found: '$'\001''|
for the first $'\001'
.
How to resolve this?
:help filter
:) For the OP, probably:help map-bar
and How to debug a mapping (sorry, wrong link earlier)The \001 is a delimiter
What's wrong withcolumn -t -s\| -o\|
??