Searching for selected text

2006-09-30 Thread Bram Moolenaar

Sometimes people ask me for a command to search for the text that is
currently visually selected.  You could add a mapping for the '/' key,
but then you lose the possibility to extend the visual area by
searching for a pattern.

Since we might need more commands in Visual mode later, and we only have
a few keys left to be used, we need to use two key combinations for
new commands in Visual mode.

I think we can start using the '' key.  Currently it doesn't do
anything.  For now we could add the commands:

/  search for the Visually selected text forward
?  same, backward

Is there a good alternative?

-- 
Any resemblance between the above views and those of my employer, my terminal,
or the view out my window are purely coincidental.  Any resemblance between
the above and my own views is non-deterministic.  The question of the
existence of views in the absence of anyone to hold them is left as an
exercise for the reader.  The question of the existence of the reader is left
as an exercise for the second god coefficient.  (A discussion of
non-orthogonal, non-integral polytheism is beyond the scope of this article.)
(Ralph Jennings)

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///


Re: Searching for selected text

2006-09-30 Thread Georg Dahn

Hi!

Bram Moolenaar wrote:

/  search for the Visually selected text forward
?  same, backward

Is there a good alternative?


I think, this is ok. For the moment I have the following lines
in my vimrc file (I found the original code in a vim tip):

--- 8 ---
 Search in Visual and Selection modes with '*' and '#'
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 . ^RMakeSearchString(@\)^M^MgV
return l:rhs
endfunction

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

(The ^R and ^M are special chars)

This does the job for me and I think, that these mappings
are rather consistent with the rest of Vim, since they
just expand the behavior of * and #.

What exactly do you plan? Which new features shall we expect?

Best wishes,
Georg





___ 
Copy addresses and emails from any email account to Yahoo! Mail - quick, easy and free. http://uk.docs.yahoo.com/trueswitch2.html


Re: Searching for selected text

2006-09-30 Thread mzyzik
I don't like this one more, but it's a good alternative:
g/
g?

Also, I feel that one day  might do something in visual; at least
visual line mode.

--Matt

On Sat, Sep 30, 2006 at 01:37:59PM +0200, Bram Moolenaar wrote:
 
 Sometimes people ask me for a command to search for the text that is
 currently visually selected.  You could add a mapping for the '/' key,
 but then you lose the possibility to extend the visual area by
 searching for a pattern.
 
 Since we might need more commands in Visual mode later, and we only have
 a few keys left to be used, we need to use two key combinations for
 new commands in Visual mode.
 
 I think we can start using the '' key.  Currently it doesn't do
 anything.  For now we could add the commands:
 
   /  search for the Visually selected text forward
   ?  same, backward
 
 Is there a good alternative?
 
 -- 
 Any resemblance between the above views and those of my employer, my terminal,
 or the view out my window are purely coincidental.  Any resemblance between
 the above and my own views is non-deterministic.  The question of the
 existence of views in the absence of anyone to hold them is left as an
 exercise for the reader.  The question of the existence of the reader is left
 as an exercise for the second god coefficient.  (A discussion of
 non-orthogonal, non-integral polytheism is beyond the scope of this article.)
   (Ralph Jennings)
 
  /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
 ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
 \\\download, build and distribute -- http://www.A-A-P.org///
  \\\help me help AIDS victims -- http://ICCF-Holland.org///


Re: Searching for selected text

2006-09-30 Thread Bram Moolenaar

Matt Mzyzik wrote:

 I don't like this one more, but it's a good alternative:
   g/
   g?
 
 Also, I feel that one day  might do something in visual; at least
 visual line mode.

g? is already used for rot13 encoding.

g/ is scheduled to be used to search inside the selected area

-- 
Eye have a spelling checker, it came with my PC;
It plainly marks four my revue mistakes I cannot sea.
I've run this poem threw it, I'm sure your please to no,
It's letter perfect in it's weigh, my checker tolled me sew!

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///


Re: Searching for selected text

2006-09-30 Thread Nikolai Weibull

On 9/30/06, Bram Moolenaar [EMAIL PROTECTED] wrote:


g/ is scheduled to be used to search inside the selected area


Hehe, I was just about to ask if such a command wouldn't be useful :-)

 nikolai


Re: Searching for selected text

2006-09-30 Thread Yakov Lerner

On 9/30/06, Georg Dahn [EMAIL PROTECTED] scribbled:

Hi!

Bram Moolenaar wrote:
   /  search for the Visually selected text forward
   ?  same, backward

 Is there a good alternative?

I think, this is ok. For the moment I have the following lines
...
vnoremap expr * SIDVisualSearch('*')
vnoremap expr # SIDVisualSearch('#')


I also use 'vmap * ...' and 'vmap # ...' to search for
text that is visual selection.In my mapping, all special chars
in visual selection are quoted to make them literal.

I think there can be two variants for search for visual selection:

1) treat visual selection as pattern
2) treat visual selection as literal text

Yakov


Re: Searching for selected text

2006-09-30 Thread Yakov Lerner

On 9/30/06, Bram Moolenaar [EMAIL PROTECTED] wrote:


Sometimes people ask me for a command to search for the text that is
currently visually selected.  You could add a mapping for the '/' key,
but then you lose the possibility to extend the visual area by
searching for a pattern.

Since we might need more commands in Visual mode later, and we only have
a few keys left to be used, we need to use two key combinations for
new commands in Visual mode.

I think we can start using the '' key.  Currently it doesn't do
anything.  For now we could add the commands:

/  search for the Visually selected text forward
?  same, backward



Do you plan to treat visual selection as pattern, or a literal text-to
search ?

Yakov


Recording of Vim BOF session

2006-09-30 Thread Bram Moolenaar

The audio recording of the Vim BOF session at the euroOSCON is now
available:

ftp://ftp.vim.org/pub/vim/stuff/20060919_BOF.wav
ftp://ftp.vim.org/pub/vim/stuff/20060919_BOF.mp3

The size of the .wav is 17 Mbyte.  It's a 8000 Hz mono recording.
The .mp3 file is about half that size and still sounds about the same.

The most notable subjects discussed:

0:00: Introduction by Bram: a bit of history, Vim 7 release, current situation
0:10: GUI Tab pages labels: more control over color/bold/etc/ of the text
0:13: file changed outside of Vim
0:23: undo tree view; search in text saved for undo
0:28: Perl integration: Vim functions in Perl directly
0:38: there are 3 match items only, need more
0:47: viper mode
0:48: seven habits of effective text editing
0:55: vertical folds
1:02: formatting text
1.10: the killer feature

Enjoy!

-- 
FIRST VILLAGER: We have found a witch.  May we burn her?
 Monty Python and the Holy Grail PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///


Re: Searching for selected text

2006-09-30 Thread Bram Moolenaar

Yakov Lerner wrote:

 On 9/30/06, Bram Moolenaar [EMAIL PROTECTED] wrote:
 
  Sometimes people ask me for a command to search for the text that is
  currently visually selected.  You could add a mapping for the '/' key,
  but then you lose the possibility to extend the visual area by
  searching for a pattern.
 
  Since we might need more commands in Visual mode later, and we only have
  a few keys left to be used, we need to use two key combinations for
  new commands in Visual mode.
 
  I think we can start using the '' key.  Currently it doesn't do
  anything.  For now we could add the commands:
 
  /  search for the Visually selected text forward
  ?  same, backward
 
 
 Do you plan to treat visual selection as pattern, or a literal text-to
 search ?

Literal text would be most useful.  For a pattern I would expect it to
be more useful to copy it from one file (e.g., help text or a Vim scrip)
and search for it in another file.

-- 
CRONE:  Who sent you?
ARTHUR: The Knights Who Say GNU!
CRONE:  Aaaagh!  (she looks around in rear) No!  We have no licenses here.
   Monty Python and the Holy editor wars PYTHON (MONTY) SOFTWARE LTD

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///


gvim segfaulting on Solaris 10

2006-09-30 Thread Laurent Blume

Hi all,

I built vim 7.0.110 on Solaris 10 U1 x86, fully patched, using Sun Studio 
11 or Solaris' GCC 3.4.3. 
Building went fine, however, test 16 failed (no output). What happens is 
that gvim fails on startup with a segfault:


$ gvim
GTK Accessibility Module initialized
Bonobo accessibility support initialized
Vim: Caught deadly signal SEGV
Vim: Finished.
Segmentation Fault (core dumped)

Just running vim works:

$ vim

~  VIM - Vi IMproved
~
~   version 7.0.110

I built it using a very simple configuration:

export PATH=/usr/bin:/usr/ccs/bin:/opt/SUNWspro/bin

LDFLAGS='-L/usr/sfw/lib -R/usr/sfw/lib' \
./configure --prefix=/opt/vim-7.0.110 \
  --enable-multibyte

And here's the pstack of the core if it can be useful:
$ pstack core.vim.14541
core 'core.vim.14541' of 14541: gvim
 fd1b0557 kill (82ba9cc, 815c0b0, 1, 82bd2e8, 0, 0) + 7
 081c183a mch_exit (1) + 8a
 0815c0b0 getout   (1) + 210
 08185884 preserve_exit (8, 82ba9fc, fd1afd8f, b, 0, 82baa8c) + c4
 081bfa19  (b, 0, 82baa8c)
 fd1afd8f __sighndlr (b, 0, 82baa8c, 81bf880) + f
 fd1a6355 call_user_handler (b, 0, 82baa8c) + 22b
 fd1a64d5 sigacthandler (b, 0, 82baa8c) + bb
 --- called from signal handler with signal 11 (SIGSEGV) ---
 fcfdf908 FcHideFont (83ff0e8, 8429280, 8429268, 80468e0) + d8
 fcfe0979 FcFontSetSort (83f8be0, 804695c, 1, 83f5d58, 1, 0) + 1c9
 fcfe0d1a FcFontSort (83f8be0, 83f5d58, 1, 0, 80469a8, 83f5d58) + ca
 fd6e8043 pango_fc_font_map_get_patterns () + 157


Any idea what's going wrong? Would it be a vim or a Solaris GNOME issue?

Thanks in advance for any hint!

Laurent


Re: Searching for selected text

2006-09-30 Thread A.J.Mechelynck

Bram Moolenaar wrote:

Sometimes people ask me for a command to search for the text that is
currently visually selected.  You could add a mapping for the '/' key,
but then you lose the possibility to extend the visual area by
searching for a pattern.

Since we might need more commands in Visual mode later, and we only have
a few keys left to be used, we need to use two key combinations for
new commands in Visual mode.

I think we can start using the '' key.  Currently it doesn't do
anything.  For now we could add the commands:

/  search for the Visually selected text forward
?  same, backward

Is there a good alternative?



 does do something, but maybe we can do without that, since :s//~/ does the 
same (repeat last substitute without the flags) -- it needs six keystrokes 
instead of one though.



Best regards,
Tony.