Re: invoking yanked register into colon command

2007-04-03 Thread John Little

Gene Kwiecinski wrote:


Me, I go to whatever I'm looking for, hit 'v', then use normal motion
commands (eg, 3e) to highlight the text in question, instead of using
the mouse.

If a single word, '*' will automagically highlight and search for the
word under the cursor.


And with

vnoremap * y:exe 'norm! /' . escape(@@, '/*.\[$^~') . \rcr

in your .vimrc, it works for more than a single word, any stuff up to a
line's worth.

HTH
John


Re: invoking yanked register into colon command

2007-04-02 Thread Georg Dahn

Hi!

There is an error: The function


function MakeSearchString(str)
return substitute(escape(@, '\\/.*$^~[]'), '\n', '\\n', 'g')
endfunction


should be

function MakeSearchString(str)
return substitute(escape(a:str, '\\/.*$^~[]'), '\n', '\\n', 'g')
endfunction

I have not seen this error before, because the function did the expected 
things even with this error.


Best regards,
Georg







RE: invoking yanked register into colon command

2007-04-02 Thread Gene Kwiecinski
after having read the user-manual. For example, I do often want to
replace a name in the text with another. What I used to do is
selecting it with mouse and type
:%s/ctrl-ins/newname/gc
Is there a way to do this with the mouse (and without retyping the
name) ?
What I want is maybe something like 'invoking a yanked register in my
colon command'

Me, I go to whatever I'm looking for, hit 'v', then use normal motion
commands (eg, 3e) to highlight the text in question, instead of using
the moose.

If a single word, '*' will automagically highlight and search for the
word under the cursor.

From there, once you highlighted the exact pattern you want, can just
use

:%s//newname/gc

as it remembers what you just looked for.  No need to reinsert it for
the 's' command.


invoking yanked register into colon command

2007-03-31 Thread Guillaume Bog

Hi vimers,

I getting used to many vim features but I still lack some skills, even
after having read the user-manual. For example, I do often want to
replace a name in the text with another. What I used to do is
selecting it with mouse and type
:%s/ctrl-ins/newname/gc
Is there a way to do this with the mouse (and without retyping the name) ?
What I want is maybe something like 'invoking a yanked register in my
colon command'

Thanks


Re: invoking yanked register into colon command

2007-03-31 Thread Christian Ebert
* Guillaume Bog on Saturday, March 31, 2007 at 23:04:34 +0800:
 I getting used to many vim features but I still lack some skills, even
 after having read the user-manual. For example, I do often want to
 replace a name in the text with another. What I used to do is
 selecting it with mouse and type
 :%s/ctrl-ins/newname/gc
 Is there a way to do this with the mouse (and without retyping the name) ?
 What I want is maybe something like 'invoking a yanked register in my
 colon command'

:help c_CTRL-R

c
-- 
Vim plugin to paste current GNU Screen buffer in (almost) any mode:
http://www.vim.org/scripts/script.php?script_id=1512


Re: invoking yanked register into colon command

2007-03-31 Thread Tobia
Guillaume Bog wrote:
 What I used to do is selecting it with mouse and type
 :%s/ctrl-ins/newname/gc
 Is there a way to do this with the mouse

I guess you mean with the keyboard.  Yes, there is.

Ctrl-R /pull to the commandline the last search pattern
Ctrl-R ...the last unnamed delete or yank
Ctrl-R *...the current selection (X11 only)
Ctrl-R +...the clipboard contents
Ctrl-R x...the contents of register x
Ctrl-R Ctrl-W   ...the current word under the cursor

See :help c_CTRL-R


Tobia


Re: invoking yanked register into colon command

2007-03-31 Thread Georg Dahn

Hi!


For example, I do often want to
replace a name in the text with another. What I used to do is
selecting it with mouse and type
:%s/ctrl-ins/newname/gc
Is there a way to do this with the mouse (and without retyping the name) ?
What I want is maybe something like 'invoking a yanked register in my
colon command'


I have the following in my vimrc file:

function MakeSearchString(str)
return substitute(escape(@, '\\/.*$^~[]'), '\n', '\\n', 'g')
endfunction

function! SIDVisualSearch(direction)
if a:direction == '#'
let l:rhs = y?
else
let l:rhs = y/
endif
let l:rhs = l:rhs . \C-R=MakeSearchString(@\)\CR\CRgV
return l:rhs
endfunction

vnoremap expr * SIDVisualSearch('*')
vnoremap expr # SIDVisualSearch('#')

vnoremap F3 y/C-R=MakeSearchString(@)CR
vnoremap S-F3 y?C-R=MakeSearchString(@)CR
vnoremap M-F3 y:%s/C-R=MakeSearchString(@)CR/

With this just select a text and by typing F3 you can search for the 
selected text and by typing M-F3 you can replace it easily. '*' 
searches forward and '#' backwards like '*' and '#' do for the word 
under the cursor in normal mode.


Best regards,
Georg







Re: invoking yanked register into colon command

2007-03-31 Thread Guillaume Bog

On 01/04/07, Georg Dahn [EMAIL PROTECTED] wrote:

Hi!

 For example, I do often want to
 replace a name in the text with another. What I used to do is
 selecting it with mouse and type
 :%s/ctrl-ins/newname/gc
 Is there a way to do this with the mouse (and without retyping the name) ?
 What I want is maybe something like 'invoking a yanked register in my
 colon command'

I have the following in my vimrc file:

function MakeSearchString(str)
 return substitute(escape(@, '\\/.*$^~[]'), '\n', '\\n', 'g')
endfunction

function! SIDVisualSearch(direction)
 if a:direction == '#'
 let l:rhs = y?
 else
 let l:rhs = y/
 endif
 let l:rhs = l:rhs . \C-R=MakeSearchString(@\)\CR\CRgV
 return l:rhs
endfunction

vnoremap expr * SIDVisualSearch('*')
vnoremap expr # SIDVisualSearch('#')

vnoremap F3 y/C-R=MakeSearchString(@)CR
vnoremap S-F3 y?C-R=MakeSearchString(@)CR
vnoremap M-F3 y:%s/C-R=MakeSearchString(@)CR/

With this just select a text and by typing F3 you can search for the
selected text and by typing M-F3 you can replace it easily. '*'
searches forward and '#' backwards like '*' and '#' do for the word
under the cursor in normal mode.

Best regards,
Georg


Thanks all of you for your answers. I grab the tip with Ctrl-R because
I have to use vim on many different computers, but will consider
adding the script when I'll refresh my vimrces.

Guillaume