[lug] Vim maps / vimrc files for html editing
Daniel Webb
lists at danielwebb.us
Mon Feb 19 01:22:08 MST 2007
On Sun, Feb 18, 2007 at 02:20:17PM -0700, dio2002 at indra.com wrote:
> Is there away for vim to do substitutions across multiple files that are
> in the same directory or lower as teh current file you're applying the
> substittion to? The idea is that once you finish the substitutions in teh
> current file, it loads the next file, etc and applies teh substitution.
> If you want, you can have it prompt you to confirm the replacement as well
> versus doing it all automatically.
>
> this is useful for changing paths in multiple files if you change your
> site structure around or duplicate a directory to a different path.. the
> ability to be prompted is very cool because sometimes paths don't need to
> change in one file for whatever reason.
If you mean dynamically (as you move around to different files) I have no idea
how you would do that. Write a Vim script, I imagine.
If you just want to edit a single file while having this capability, go to the
file's directory, and do:
find . -name '*.html' | xargs vim
to start Vim with all the files you might want to find/replace, then
:ed file.html
to edit the particular file, then
:argdo %s/from/to/gce
to do the interactive find/replace.
I used argdo find/replace nearly every day when I was doing a lot of
development work. In my opinion it's one of the killer features that
distinguishes what I consider a "real" editor from a toy. It makes it very
easy to do a lot of things in large projects that you can't do with toy
editors.
More information about the LUG
mailing list