Monday, July 22, 2013

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

On Monday, July 22, 2013 4:08:28 AM UTC+2, Tim Chase wrote:
> [copying the list, as your reply came directly to me. You may want
>
> to check your reply before sending]
>
>
>
> On 2013-07-21 22:29, wrote:
>
> > Thank you very much for your reply Tim.
>
> >
>
> > > 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).
>
> >
>
> > Yes you're right
>
> > shell=cmd.exe
>
> > >
>
> > > 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.
>
> >
>
> > shelltype: option not supported
>
> > shellpipe=>%s 2>&1
>
> > noshellslash
>
> > shellredir=>%s 2>&1
>
> > shellquote=
>
> > shellxquote=
>
> > shellcmdflag=/c
>
>
>
> Someone with a Win32+cygwin environment might be able to step in here
>
> and compare their settings with yours.
>
>
>
> It might also help to know whether you're running vim-for-Windows
>
> (the "Windows" version of vim) or a vim built to be cygwin aware. I
>
> seem to recall that there were some differences in them.
>
>
>
>
>
> > > 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).
>
> >
>
> > The windows shell is working very well as intermetter to the bash
>
> > shell, just these pipes and quotes problems.
>
> > I noted much more problems when I define the bash shell as shell in
>
> > vim.
>
>
>
> I've found that cmd.exe's parameter-quoting and piping are somewhat
>
> less predictable when compared to *nixy shells
>
>
>
>
>
> > I use unix sort command because I've found it much more flexible as
>
> > the vim sort command.
>
> > p.e. to sort by column(nr) 5 and if there are equals sort by
>
> > column(nr) 12, isn't possible (i.m.o) with vim sort command.
>
> > I use it also to sort by real columns (and define a separator to
>
> > number columns), like the one in my example.
>
>
>
> since you have the full expressive power of Vim regexps at your
>
> disposal with the internal sort, your example could be done with
>
> either of
>
>
>
> :%sort /|/
>
> :%sort n /|/
>
>
>
> (depending on whether you wanted numeric sorting or
>
> ASCII/lexicographical sort order)
>
>
>
> For subsequent columns it gets a little messier, but you can do it.
>
> For 2 preceding columns (i.e., sorting on the 3rd column), you can do
>
>
>
> :%sort /^\([^|;:]*[|;:]\)\{2}/
>
>
>
> to allow for any of a pipe, colon, or semi-colon as delimiters.
>
>
>
> All the basics that you can do with GNU sort should be pretty doable
>
> with Vim's internal sort, except perhaps some of the more edge-case
>
> sort-orders (such as --month-sort, --human-numeric-sort and
>
> --version-sort). I don't use those very often and far more
>
> frequently have need to sort by some regexp like vim provides.
>
>
>
> -tim

Thank you very much Tim.
Sorry that my reply came to you and not to the list.

Thanks also for your regex.
This one is maybe even easier:

:%sort! n /^\(.\{-}\zs[|;:]\)\{'.columnnr.'}/

Hope that someone will answer also to the shell settings.
(btw I use the vim windows version (not the cygwin vi version).

Sure I will use the vim sort command a bit more (and have to study it a bit more)

I still use the unix sort command to sort single columns (p.e.\\%2v)
P.e. to sort by column 4 and if there are equals sort by column 8.
This is very easy to do with the unix sort command, it seems to me much more difficult with the vim sort command.

However, thanks so far.
Rameo

--
--
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:

Post a Comment