[prev in list] [next in list] [prev in thread] [next in thread]
List: vim
Subject: Re: Newbie question: How to give a command over they current file and all other files in directory
From: "Tony Mechelynck" <antoine.mechelynck () skynet ! be>
Date: 2005-09-28 8:55:52
Message-ID: 001001c5c40a$6e45ea80$fdebc950 () tonylap
[Download RAW message or body]
----- Original Message -----
From: "Eric Leenman" <ELeenman@greefa.nl>
To: "vim" <vim@vim.org>
Sent: Wednesday, September 28, 2005 10:28 AM
Subject: Newbie question: How to give a command over they current file and
all other files in directory
> Hi,
>
> If I have one file open in gVim, say file1.c,
> how can I give a command in gVim which would apply to file1.c but also
> to all other .c files in the directory which are not open in gVim?
>
> For Example to:
> - rename everywhere global var gWriteFlag into gWrFlg
> :%s/gWriteFlag/gWrFlg
> - to remove all spaces at the end of lines
> :%s= *$==
>
>
> Rgds,
> Eric
" change to directory of current file
:cd %:p:h
" define new arguments list
:args *.c
" do something on all files in the list
:argdo 1,$s/\<gWriteFlag\>/gWrFlg/g
or
:argdo 1,$s/\s*$//
Note: for the first substitution, you will probably want to check for word
boundaries (not replace BlogWriteFlaggingRoutine by BlogWrFlggingRoutine)
and replace all matches, even several on a line (hence the g flag).
see
:help :args
:help :argdo
HTH,
Tony.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic