> Hi,
>
> I am faced with the following issue. I have a resolve.conf file made
> of sections like
>
> #Company IT nameservers
> nameserver 1.2.3.4
> nameserver 1.2.3.5
> nameserver 1.2.3.6
>
> #Lab1 nameservers
> #nameserver 10.1.2.3
> #nameserver 10.1.2.4
>
> #Lab2 nameservers
> #nameserver 20.1.2.2
>
> I want to use vim -c to do to tasks.
> a- comment out a given section (say section that starts with comment
> #Company IT )
> b- uncomment a given section (say section that starts with comment
> #Lab1)
I'll leave it to you to come up with the -c arguments, but here's
an example of what I do to edit a file within a shell script:
vim -X -E -s -u NONE -c 'set wm=1' -c '%s/\n\{4,}/\r\r\r/' -c 'v/http:\/\/letters\.washingtonpost\.com\//normal gqq' -c 'wq' "$@"
That should all be one line.
> In an interactive VIM session that would have been trivial (/
> <pattern> then vap then s/^/#/ or s/^#// for example). However I want
> to embed this in a bash script so it must be non interactive.
> I can always use perl/python for this but I feel like its bringing a
> cannon to kill the fly which I usually try to avoid.
I think that vim is the cannon in this case. It's a large program;
it has to read the entire file into memory rather than reading only
the part it needs to perform the operation; it doesn't work in a
pipeline except at the end. I used it in the example above because
I knew how to solve the problem using vim, didn't want to spend the
time figuring out how to do it in a scripting language, and didn't
care about performance.
Regards,
Gary
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment