Finding previous space or tab

0 views
Skip to first unread message

epanda

unread,
Jan 4, 2010, 12:31:04 PM1/4/10
to vim_use
Hi,


I am in visual selection and encouter a problem finding the previous
tab or space

norm vF y

My aim is to visual select a word and then copy it.

Thanks

Tim Chase

unread,
Jan 4, 2010, 12:58:59 PM1/4/10
to vim...@googlegroups.com

A couple items: first, you may want to read up on text
objects...there are "inner word" and "inner WORD" text objects
that may simplify your selection:

norm yiw

without needing to move around the end-point anchors of a visual
selection.

Additionally, for scripting purposes, you may be interested in

expand('<cword>')

For more info, you can read at

:help iw
:help text-object
:help expand()

-tim


epanda

unread,
Jan 5, 2010, 4:36:24 AM1/5/10
to vim_use

I will use expand('<cword>') but how can I expand something like
that :
namespace::func
namespace:~bar

Ben Fritz

unread,
Jan 5, 2010, 9:56:44 AM1/5/10
to vim_use

You already have the better way to accomplish your task (using one of
the word text objects, :help text-objects) however in general ":normal
vF " ought to work to select text from the cursor up to and including
the previous space. What was it doing instead?

epanda

unread,
Jan 5, 2010, 10:33:36 AM1/5/10
to vim_use

eg : cursor is on (

void\tfoo:bar (
void foo:bar (

'norm hvF ' works only in case 2, I would like the same command to
work on both cases.
Thanks

Ben Fritz

unread,
Jan 6, 2010, 10:37:16 AM1/6/10
to vim_use

On Jan 5, 9:33 am, epanda <callingel...@hotmail.fr> wrote:
> eg : cursor is on (
>
> void\tfoo:bar (
> void foo:bar (
>
> 'norm hvF '   works only in case 2, I would like the same command to
> work on both cases.

Oh, so it would fail when non-space whitespace was the word separator.
Then, how about ":norm vb" or ":norm v?\s"? Of course, if all you want
is to select a full word, the best would be using <cword> or <cWORD>
or the iw text object the iW text object.

Reply all
Reply to author
Forward
0 new messages