Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
expand('<cword>')

The above can select the word from cursor, but I want to select more, that is the text delimited by the cursor and the first white space.

How to do that in vim script?

UPDATE

I'm seeking a flexible way to do string manipulation in vi script.

share|improve this question
1  
Did you try <cWORD>? – romainl Jun 18 '12 at 13:14
    
@romainl, that seems to be working, but is there a more flexible way to specify a regex so that I can match the text as I like? – vimer Jun 18 '12 at 13:29
    
You should add more background to your question. – romainl Jun 18 '12 at 13:33
    
@romainl,I'm quite experienced in manipulating string in various programing languages, but doesn't find a flexible way to do it in vi script yet.. – vimer Jun 18 '12 at 13:45
1  
That's not the kind of background I was asking for. What is your goal? How do you plan to execute the function/command? Did you read :help functions? – romainl Jun 18 '12 at 13:58

Enter the command vf

  1. v: visual selection
  2. f: find
  3. : space

Please note that this way the space is selected as well.

share|improve this answer
    
This seems not working in ` Vi IMproved 7.3`.Just to make things clearer,I need to pass the selected text to another function. – vimer Jun 18 '12 at 11:34
  1. v: start visual selection
  2. t<space>: go to next occurrence of the input character (in this case )
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .