On Tue, Aug 22, 2017 at 5:22 AM, Miles Cranmer
<[email protected]> wrote:
> I wrote this tiny wrapper called "vims"
> (https://github.com/MilesCranmer/vim-stream) which makes it easier to use
> vim movement commands from the terminal, in a sed-like fashion.
>
> Basically, running:
>
> git status | vims -r 'modified' 'dd' -l 'df:'
>
> (-r = run a normal-mode command on every line not matching regexp)
> (-l = run a normal-mode command on every line)
>
> Gets translated into
>
> git status | vim - -nes -c '%v/modified/exe "norm dd"' -c ':%g/.*/exe "norm
> df:"' -c :%p -c ':q!'
>
> Which will delete all lines without "modified" (using dd), then on each line
> (-l), it will delete from char 0 to the first : character.
>
> Some people think I should just use sed/awk, but I've found this little
> wrapper VERY useful, and have started using it everywhere.
>
> Now, I am writing a script that does the following: when given an integer x,
> it deletes all lines with integers < x. It does this using vims:
>
> for x in $(seq 0 $1); do
>     NUMS_TO_AVOID+=("%g/\<$x\>/d_")
> done
> vims "${NUMS_TO_AVOID[@]}" | less
>
> However, when I get to a certain integer (I think 8?), I am told that I have
> hit some limit of commands:
>
> VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jul  9 2015 23:58:42)
> Too many "+command", "-c command" or "--cmd command" arguments
> More info with: "vim -h"
>
> I've never entered so many commands into vims/vim before, but I don't see a
> reason there should be a limit. Of course, I could also just change this to
> be something like "%g/1\|2\|3\|4...", but that just fixes this single test
> case.
>
> Is there any way I can release this limit?

The documented limit is 10 -c or + or -S arguments (to be run after
reading the first file and processing its modelines if any) and 10
--cmd arguments (to be run before reading the vimrc).

If you want to run more than 10+10 ex-commands at startup in the next
Vim instance (and not every time, or they would go in the vimrc), the
way to do it is to write them into a script. You can then pass this
script as argument to an -S argument, which will count as one command
no matter how many ex-commands that script contains. Or -S not
followed by a filename (i.e. at the end of the command-line or
immediately before another dash option) will implicitly source the
file Session.vim in the current directory. That can be any Vim script,
it doesn't have to have been created by the :mksession command. It
could for instance have been written by your wrapper immediately
before invoking Vim.

See
        :help -c
        :help --cmd
        :help -S


Best regards,
Tony.

-- 
-- 
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui