Monday, May 23, 2011

Re: bash script using vim commands?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJN2o/LAAoJEJtdmT+DbynAUvAH/2GqNs0/oKFMA4QWSf6Q3Y3K
OeOr1HtJhyZi/Sruxt3C+POEmjL96vk+ZsSd5Gxjg1XwdSWiX0toZEiCYo/i5qt2
ig7NzNUiJWI+eBhycECQ/oEqclFjGwaS6NaS5Bp5BaXObNtLlklk12WGj03c5jcT
ScjUv3bCu5Mpur/5rG6apqNmyFb6qCk24/TBdkFWlVdD2DVaAKVxTUPih56VDKP8
4dG7e3W0/iiOFhXeC/MyAh7MnFD2ec9tThFv4klq28+biqNlG4VO5gF5INuMRE8S
GmVUhNwvQuFulkgQ8FuI0lkZuIzjIBYX3jZKrMjalqfSlydvYFBDTI7TXj+ZK4Q=
=A7Zl
-----END PGP SIGNATURE-----
Antonio Recio wrote:
> I would like to execute a bash script from the terminal with two
> vim commands.

Vim can be driven from a Bash script. Here's an example.

Save this as "noblanks.vim":

" remove blank lines
:g/^$/d
" write, quit
:wq

Usage:

$ vim -es < noblanks.vim file_with_blanks.txt

See also:
* http://superuser.com/questions/22455/vim-what-is-the-ex-mode-for-batch-processing-for/22500#2250
* :help -e
* :help -s-ex
* :help -n

No comments:

Post a Comment