Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Reference to visual selection in :rubydo
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
mkorfmann  
View profile  
 More options Mar 14 2011, 12:01 pm
From: mkorfmann <m...@korfmann.info>
Date: Mon, 14 Mar 2011 09:01:03 -0700 (PDT)
Local: Mon, Mar 14 2011 12:01 pm
Subject: Reference to visual selection in :rubydo
Hey,

how can I access the current selected text within the :rubydo command?
The current line is accessible by the $_ global variable, but I was
not able to find such a variable for the current visual selection.

Many thanks,
mkorfmann


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ken Bloom  
View profile  
 More options Mar 15 2011, 12:23 pm
From: Ken Bloom <kbl...@gmail.com>
Date: Tue, 15 Mar 2011 11:23:40 -0500
Local: Tues, Mar 15 2011 12:23 pm
Subject: Re: Reference to visual selection in :rubydo

On Mon, 14 Mar 2011 09:01:03 -0700, mkorfmann wrote:
> Hey,

> how can I access the current selected text within the :rubydo command?
> The current line is accessible by the $_ global variable, but I was not
> able to find such a variable for the current visual selection.

I've done this with VIM.evaluate("@*")

To overwrite the selection with the contents of the variable new_text,
I've done:

old_x=VIM.evaluate("@x")
VIM::evaluate("setreg('x',\"#{new_text.vim_escape}\")")
VIM::command(":normal vgv\"xP")
VIM::evaluate("setreg('x',\"#{old_x.vim_escape}\")")

Where vim_escape is defined as follows:

   class String
      #escapes a string so it can be concatenated into
      #a call to VIM.evaluate
      def vim_escape
         result=dup
         result.gsub!("\\",'\\\\\\\\')
         result.gsub!('"','\"')
         result
      end
   end

--
Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Manuel Korfmann  
View profile  
 More options Mar 15 2011, 1:22 pm
From: Manuel Korfmann <m...@korfmann.info>
Date: Tue, 15 Mar 2011 18:22:40 +0100
Local: Tues, Mar 15 2011 1:22 pm
Subject: Re: Reference to visual selection in :rubydo

Thank you, any help with vimscript is highly appreciated . Today I wasted 2
hours, figuring out why I couldn't access a function's parameter :) .
Do you know a good tutorial, which walks you through the editor api ?
Probably discussing things like how one can replace text or how one can get
the character under the cursor ?

Many thanks .


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »