Sunday, July 21, 2013

Re: using !sort in windows commandline: passing special characters

On 2013-07-21 11:13, rameo wrote:
> I use cygwin on my windows system to use unix commands from vim
> commandline.
>
> This is written in my text file:
> Adam|12345
> Bob|34567
> Joe|56789
> Sam|45678
> Wendy|23456
>
> When I use:
>
> :%!sort -k2n -t'|'
>
> it gives an error:
> ''' is not recognized as an internal or external command, operable
> program or batch file.

This sounds like cmd.exe is being used for your shell processing of
your command, rather than some other (bash?) shell. Within vim, what
is the result of

:set shell?

I'm presuming it's something like "C:\...\cmd.exe" rather than
"C:\...\bash.exe" (or some such cygwin shell).

As directed at ":help 'shell'", you might also want to investigate
your settings for 'shelltype', 'shellpipe', 'shellslash'
'shellredir', 'shellquote', 'shellxquote' and 'shellcmdflag' to
figure out what they're set to. Including those values in a reply
may help track down further issues if pointing 'shell' at a *nixy
shell rather than a Win32 shell.

If it's cmd.exe, you might try setting the value of 'shell' to the
path where you'll find your preferred *nixy shell as installed by
cygwin, and re-test (and providing the results here if it doesn't
work for you).

> Same problem when I use '>' and '<' as separator.
> Escaping doesn't resolve my problem.
> I don't have problems with other separators as ';', ')', '\\', '='
> and many others.

I suspect this is a similar issue, and that you might have trouble
with "&" as a separator depending on where you put it in your
command-line.

> Is it possible to use regex in the sort command. No info is written
> in the manual and it doesn't work in my vim.

To the external GNU/cygwin sort that you're calling? I don't believe
so. That said, vim has had a built-in ":sort" command since at least
v7.0 (possibly late 6.x series builds too) which *does* support
sorting on a regexp, which you can read about at

:help :sort

(you can skim down to the section on /pattern/ if that's your primary
concern)

-tim












--
--
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.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: