Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
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

2 Answers 2

  1. v: start visual selection
  2. t<space>: go to next occurrence of the input character (in this case )
share|improve this answer

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.