On Thu, Nov 05, 2009 at 10:09:47AM -0500, Chris Suter wrote:
> On Thu, Nov 5, 2009 at 6:27 AM, Wu, Yue <[email protected]> wrote:
> 
> >
> > Hi list,
> >
> > Let's begin with my issue:
> >
> > I want to get some strings which matches with a particular regex, say
> > '@\S\+',
> > then category them into an array, so I have to know how many types of the
> > strings a file has, so I must search all of them, which matches with
> > '@\S\+',
> > then category them into an array. How to achieve it in vimscript?
> >
> > Here is a example case:
> >
> > I have a file, which has some strings, say @tag1, @tag2, @tag3, but I don't
> > know
> > the names of them, so I have to find all of them firstly, then test if a
> > string
> > has been in the array, if not, then use add() to add them into an arry.
> >
> > I don't know if I have describe the issue clearly, if not, please let me
> > know,
> > thank you!
> >
> 
> First, open an empty buffer window with <C-w>n -- this should open a new
> window above the window with your file, assuming you only had one window
> open to start.
> 
> Now, type <C-w>j to return down to the bottom window and do :%g/@\S\+/normal
> yaW^WkGo^[p^Wj
> 

Thanks, it does the trick, I'm sorry I misled you with the concept of array and
list in vim. Still some issues exist:

1) It needs external tools.

2) It needs some extra steps, e.g., open a new buffer.

3) It's really dirty :)

I needs some way like this:

normal gg0                  " Go to the start of the file
for search('\...@\s\+')        " Searching until reaches the end of file
  let t = getCurrentTag     " Assign the current tag to t
  if index(lst, t) == -1    " If t isn't in the list
      add(lst, t)           " Add it into lst
  endif
endfor
   

-- 
Hi,
Wu, Yue

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to