Re: Copying everything (not the complete line, only the matching pattern) which matches a pattern
Did you try using the Pippo() function from foo.vim , as I suggested in my previous post? http://www.vim.org/script.php?script_id=72 HTH --Benji Fisher On Thu, Jun 01, 2006 at 10:13:22AM +0530, SHANKAR R-R66203 wrote: This is assuming that the each line has only one matching pattern. After hit and trial I have used the macro to do that. But want to have some cute solution. Regards, Shankar
RE: Copying everything (not the complete line, only the matching pattern) which matches a pattern
This will copy the entire line. I do not want to copy the entire line, but just the pattern. Regards, Shankar -Original Message- From: Vishnu [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 31, 2006 3:53 PM To: SHANKAR R-R66203 Cc: vim@vim.org Subject: RE: Copying everything which matches a pattern Hi Shankar, :g/pattern/t$ t - copy to address $ you can call function instead of t$ ~Vishnu -Original Message- From: SHANKAR R-R66203 [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 31, 2006 3:41 PM To: 'vim@vim.org' Subject: Copying everything which matches a pattern Hi Vimmers, I want to copy everything that matches a search pattern. For example, if my search pattern is /\$.*s I want to copy all the patterns that matches this into a buffer. How can I do this ? Regards, Shankar
RE: Copying everything (not the complete line, only the matching pattern) which matches a pattern
Hi Shankar, 1. Get the pattern matching lines in a separate buffer :g/pattern/t$ 2. :%s/^.*\(your-pattern\).*$/\1/ ~VIshhu -Original Message- From: SHANKAR R-R66203 [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 31, 2006 4:06 PM To: 'Vishnu' Cc: vim@vim.org Subject: RE: Copying everything (not the complete line, only the matching pattern) which matches a pattern This will copy the entire line. I do not want to copy the entire line, but just the pattern. Regards, Shankar -Original Message- From: Vishnu [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 31, 2006 3:53 PM To: SHANKAR R-R66203 Cc: vim@vim.org Subject: RE: Copying everything which matches a pattern Hi Shankar, :g/pattern/t$ t - copy to address $ you can call function instead of t$ ~Vishnu -Original Message- From: SHANKAR R-R66203 [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 31, 2006 3:41 PM To: 'vim@vim.org' Subject: Copying everything which matches a pattern Hi Vimmers, I want to copy everything that matches a search pattern. For example, if my search pattern is /\$.*s I want to copy all the patterns that matches this into a buffer. How can I do this ? Regards, Shankar
Re: Copying everything (not the complete line, only the matching pattern) which matches a pattern
It depends on what you mean by a buffer. The basic idea of using :g should work, and there are a lot of different ways to use it. For example, :let @a = :g/\c\a*/let @a .= matchstr(getline(.), @/) . \n will copy all words starting with c into the a register. You cna then do :new :put a if you want to put the text into a buffer. (Or use ap in Normal mode.) Problem: this only grabs the first pattern that appears on a line. Solution: use the Pippo() function from foo.vim, my file of sample vim functions: http://www.vim.org/script.php?script_id=72 HTH --Benji Fisher On Wed, May 31, 2006 at 04:06:20PM +0530, SHANKAR R-R66203 wrote: This will copy the entire line. I do not want to copy the entire line, but just the pattern. -Original Message- From: Vishnu [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 31, 2006 3:53 PM Hi Shankar, :g/pattern/t$ t - copy to address $ you can call function instead of t$ -Original Message- From: SHANKAR R-R66203 [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 31, 2006 3:41 PM Hi Vimmers, I want to copy everything that matches a search pattern. For example, if my search pattern is /\$.*s I want to copy all the patterns that matches this into a buffer. How can I do this ?