A question about the usage of cscope ?

2010-04-22 Thread robert song

hello, everyone.
If I search for a string in the source code,
by typing :cs f t foo
then a list of the results will be shown, but I can't search quickly
in the list, but watch line by line to find the one I search for.
Is there any tip that help to solve the problem?
For example, save the list to buffer?

Thank you for your help.
Regards,
  Robertsong

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: backspace creates odd multibyte characters

2010-04-22 Thread Christian Brabandt
On Thu, April 22, 2010 8:57 am, Tarjei wrote:
> Hi, this is either a bug or a feature causing bugs :)

It is a feature.
> My problem is that sometimes when I edit a file in vim, and I press
> backspace and then enter another character, vim inserts an odd
> character in some outlying UTF-8 plane. This is obviously troublesome
> as the character often looks almost like the one I just removed, but I
> end up with scripts that do not compile.
>
> Is there a way to remove this feature?
>
> It seems to be found in all versions of vim I work with (RHEL4/5,
> Ubuntu ++) and it is a major irritant.

:set nodigraph

See :h 'digraph'

regards,
Christian

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: A question about the usage of cscope ?

2010-04-22 Thread Christian Brabandt
On Thu, April 22, 2010 9:21 am, robert song wrote:
> If I search for a string in the source code,
> by typing :cs f t foo
> then a list of the results will be shown, but I can't search quickly
> in the list, but watch line by line to find the one I search for.
> Is there any tip that help to solve the problem?
> For example, save the list to buffer?

See :h 'csqf' and :h csqf and possibly :h quickfix

regards,
Christian


-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: A question about the usage of cscope ?

2010-04-22 Thread Xavier de Gaye
On Thu, Apr 22, 2010 at 9:21 AM, robert song wrote:
>
> If I search for a string in the source code,
> by typing :cs f t foo
> then a list of the results will be shown, but I can't search quickly
> in the list, but watch line by line to find the one I search for.


Open the quickfix window and leave it open for all following cscope
commands:

:cwindow

You can then search the cscope result list in the quickfix window.
Hit  on the current line in the quickfix window to open the
corresponding buffer at the corresponding cscope result.


Xavier

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: backspace creates odd multibyte characters

2010-04-22 Thread Tarjei
Hi,

On 22 apr, 09:41, "Christian Brabandt"  wrote:
> On Thu, April 22, 2010 8:57 am, Tarjei wrote:
> > Hi, this is either a bug or a feature causing bugs :)
> It is a feature.
Ok, I cannot understand why it is enabled by default.
>
> > My problem is that sometimes when I edit a file in vim, and I press
> > backspace and then enter another character, vim inserts an odd
> > character in some outlying UTF-8 plane. This is obviously troublesome
> > as the character often looks almost like the one I just removed, but I
> > end up with scripts that do not compile.
>
> > Is there a way to remove this feature?
>
> > It seems to be found in all versions of vim I work with (RHEL4/5,
> > Ubuntu ++) and it is a major irritant.
>
> :set nodigraph
>
> See :h 'digraph'

GREAT!!!

I cannot explain how happy I am to remove this irritant.

Regards,
Tarjei
>
> regards,
> Christian
>
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visithttp://www.vim.org/maillist.php
>
> Subscription settings:http://groups.google.com/group/vim_use/subscribe?hl=en

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: backspace creates odd multibyte characters

2010-04-22 Thread Michael Henry
On 04/22/2010 04:52 AM, Tarjei wrote:
> Hi,
>
> On 22 apr, 09:41, "Christian Brabandt"  wrote:
>> On Thu, April 22, 2010 8:57 am, Tarjei wrote:

>>> Hi, this is either a bug or a feature causing bugs :)

>> It is a feature.

> Ok, I cannot understand why it is enabled by default.

Vim's compiled-in default value for 'digraph' is off (as shown
by :help 'digraph'), so some configuration file must be setting
it.  You can determine where it's being set using the :verbose
command with :set, like this:

:verbose set digraph?

See :help set-verbose for more information.

Michael Henry

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: Doing Unix on Windows

2010-04-22 Thread Efraim Yawitz
On Thu, Apr 22, 2010 at 9:22 AM, pansz  wrote:

>
> meino.cra...@gmx.de 写道:
>
>
>>  I would like to get back some of that functionality
>>  mainly of text related Unix tools via vim.
>>
>>
> Install Cygwin on windows and install Mintty from googlecode, use Mintty as
> your terminal emulator and Cygwin/bash as your shell, use the vim provided
> by Cygwin.
>
> Then you'll feel at home on Windows.
>

I think what he wants is to be able to use Vim as a stream editor, etc.
since he is not allowed to install things like Cygwin or GnuWin32 utilities
at work.

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: How to use a map on visually high-lighted text?

2010-04-22 Thread MK
This is almost exactly what you want. I started using it a while
ago and it is pretty great for html:

http://www.vim.org/scripts/script.php?script_id=1697

This is the "surround" plug-in.  If you google "vim surround plugin"
there are a few web videos showing how it works, so I won't bother
saying too much.  Basically you can place the cursor somewhere and do
stuff like "yss" and the line is wrapped with  .

There is a visual block mode.  You highlight a block, hit capital S,
type the tag (eg, ) and the block is wrapped.

For some reason googlegroups is rejecting my email so I tried sending
this several times, sorry if you got multiple copies.

-- 
MK 

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: Doing Unix on Windows

2010-04-22 Thread Ben Fritz


On Apr 21, 9:52 pm, meino.cra...@gmx.de wrote:
>  At work I am not allowed all that nice gimmicks like
>  grep, find, sed etc. which were ported to windows also
>  due to security reasons.
>
>  I would like to get back some of that functionality
>  mainly of text related Unix tools via vim.
>
>  First step into that direction is the answer to
>  the question, whether it would be possible to
>  apply a certain "command" (here, I mean with
>  "command" anything which does something with
>  text) to a bunch of files of a certain
>  pattern in a directory from within vim.
>

A few possibilities I know of:

1. Use a loop construct in Vim (for, while), with the glob() function,
to do something to each file returned by the function.
2. Launch Vim with all the files you want (which I think can use
wildcards) and use the :bufdo or :argdo commands.
3. Modify/use the argument list within Vim, and use the :argdo
command. See :help argument-list and following help sections and
links.
4. Use Vim's command-line options to run the commands you want, within
a "for" loop in a cmd.exe shell. Of particular use would be the -c and
--cmd command-line options to Vim, and the following reference page
for the available DOS-style commands (including for loops):
http://technet.microsoft.com/en-us/library/cc778084(WS.10).aspx

You specifically mentioned the grep and find commands. Vim has a :find
command (though the glob() function is more like the Unix find command
I think), and also a :grep command (which by default on Windows will
use the 'findstr' utility, not nearly as powerful as grep), and
finally a :vimgrep command (which is entirely built-in, allowing you
to use the full power of Vim's regular expressions). For the last two
commands I mention, obviously you can see the :help, but also take a
look here:

http://vim.wikia.com/wiki/Find_in_files_within_Vim

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: Doing Unix on Windows

2010-04-22 Thread meino . cramer
winterTTr  [10-04-22 17:16]:
> On Thu, Apr 22, 2010 at 10:52 AM,  wrote:
> 
> >
> > Hi,
> >
> >  at home I am using Vim on Linux.
> >  at work I am using Vim on Windows.
> >  I am a Unixxer...
> >
> >  At work I am not allowed all that nice gimmicks like
> >  grep, find, sed etc. which were ported to windows also
> >  due to security reasons.
> >
> >  I would like to get back some of that functionality
> >  mainly of text related Unix tools via vim.
> >
> >  First step into that direction is the answer to
> >  the question, whether it would be possible to
> >  apply a certain "command" (here, I mean with
> >  "command" anything which does something with
> >  text) to a bunch of files of a certain
> >  pattern in a directory from within vim.
> >
> >  Unfortunately I have that queston but the
> >  answer is missing ... ;o)
> >
> >  best regards
> >  mcc
> >
> 
> You can try Cygwin or MSYS with MinGW.
> You can fetch the detail information about them from google, and make a
> decision.
> 
> 
> > --
> > Please don't send me any Word- or Powerpoint-Attachments
> > unless it's absolutely neccessary. - Send simply Text.
> > See http://www.gnu.org/philosophy/no-word-attachments.html
> > In a world without fences and walls nobody needs gates and windows.
> >
> > --
> > You received this message from the "vim_use" maillist.
> > Do not top-post! Type your reply below the text you are replying to.
> > For more information, visit http://www.vim.org/maillist.php
> >
> > Subscription settings:
> > http://groups.google.com/group/vim_use/subscribe?hl=en
> >

As I tried to explain with my broken English, I am not allowed to
install anything on my Windows-PC.
Sorry...
The only tool I have is: Vim.


> 
> -- 
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php

-- 
Please don't send me any Word- or Powerpoint-Attachments
unless it's absolutely neccessary. - Send simply Text.
See http://www.gnu.org/philosophy/no-word-attachments.html
In a world without fences and walls nobody needs gates and windows.

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Doing Unix on Windows

2010-04-22 Thread meino . cramer
pansz  [10-04-22 17:16]:
> 
> meino.cra...@gmx.de 写道:
> >Hi,
> > at home I am using Vim on Linux.
> > at work I am using Vim on Windows.
> > I am a Unixxer...
> > At work I am not allowed all that nice gimmicks like
> > grep, find, sed etc. which were ported to windows also  due to 
> >security reasons.
> > I would like to get back some of that functionality
> > mainly of text related Unix tools via vim.
> 
> Install Cygwin on windows and install Mintty from googlecode, use 
> Mintty as your terminal emulator and Cygwin/bash as your shell, use the 
> vim provided by Cygwin.
> 
> Then you'll feel at home on Windows.
> 
> 
> That is what I would like to install on every Windows computer.
> 
> -- 
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
> 
> Subscription settings: 
> http://groups.google.com/group/vim_use/subscribe?hl=en
> 

As I tried to explain with my broken English, I am not allowed to
install anything on my Windows-PC.
Sorry...
The only tool I have is: Vim.



-- 
Please don't send me any Word- or Powerpoint-Attachments
unless it's absolutely neccessary. - Send simply Text.
See http://www.gnu.org/philosophy/no-word-attachments.html
In a world without fences and walls nobody needs gates and windows.

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


regex for a range that has a given number?

2010-04-22 Thread Peng Yu
I frequently need to search for citations in papers by citation
numbers.

For exmaple, something like [7] [2-8] [2,4,8-10] in the maintext
represent what articles that are listed in the bibliography are cited.
Now, I want to search for where it cites citation number 7 in the
maintext (in this example, it is cited the three places in the
maintext).

But I don't see a very general way to search for such citation. I
suppect this may not be done by regex for every cases. But I'm not
sure. Do anybody have a good solution?

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: Doing Unix on Windows

2010-04-22 Thread meino . cramer
Ben Fritz  [10-04-22 17:20]:
> 
> 
> On Apr 21, 9:52 pm, meino.cra...@gmx.de wrote:
> >  At work I am not allowed all that nice gimmicks like
> >  grep, find, sed etc. which were ported to windows also
> >  due to security reasons.
> >
> >  I would like to get back some of that functionality
> >  mainly of text related Unix tools via vim.
> >
> >  First step into that direction is the answer to
> >  the question, whether it would be possible to
> >  apply a certain "command" (here, I mean with
> >  "command" anything which does something with
> >  text) to a bunch of files of a certain
> >  pattern in a directory from within vim.
> >
> 
> A few possibilities I know of:
> 
> 1. Use a loop construct in Vim (for, while), with the glob() function,
> to do something to each file returned by the function.
> 2. Launch Vim with all the files you want (which I think can use
> wildcards) and use the :bufdo or :argdo commands.
> 3. Modify/use the argument list within Vim, and use the :argdo
> command. See :help argument-list and following help sections and
> links.
> 4. Use Vim's command-line options to run the commands you want, within
> a "for" loop in a cmd.exe shell. Of particular use would be the -c and
> --cmd command-line options to Vim, and the following reference page
> for the available DOS-style commands (including for loops):
> http://technet.microsoft.com/en-us/library/cc778084(WS.10).aspx
> 
> You specifically mentioned the grep and find commands. Vim has a :find
> command (though the glob() function is more like the Unix find command
> I think), and also a :grep command (which by default on Windows will
> use the 'findstr' utility, not nearly as powerful as grep), and
> finally a :vimgrep command (which is entirely built-in, allowing you
> to use the full power of Vim's regular expressions). For the last two
> commands I mention, obviously you can see the :help, but also take a
> look here:
> 
> http://vim.wikia.com/wiki/Find_in_files_within_Vim
> 
> -- 
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
> 
> Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en
> 

Hi Ben,

 thanks for the hints!!! :)

 I mentioned those both tools because...they just jumped into my mind
 in the moment I wrote the mail since I know them from vim :) 
 but I haven't explored them deeply...

 I will experiment with vim in conjunction with your help and will
 see how much *nix* I will get into my the Windows... ;)

 Keep hacking!
 mcc

-- 
Please don't send me any Word- or Powerpoint-Attachments
unless it's absolutely neccessary. - Send simply Text.
See http://www.gnu.org/philosophy/no-word-attachments.html
In a world without fences and walls nobody needs gates and windows.

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Doing Unix on Windows

2010-04-22 Thread Benjamin R. Haskell
On Thu, 22 Apr 2010, meino.cra...@gmx.de wrote:

> pansz  [10-04-22 17:16]:
> > 
> > meino.cra...@gmx.de 写道:
> > >Hi,
> > > at home I am using Vim on Linux.
> > > at work I am using Vim on Windows.
> > > I am a Unixxer...
> > > At work I am not allowed all that nice gimmicks like
> > > grep, find, sed etc. which were ported to windows also  due to 
> > >security reasons.
> > > I would like to get back some of that functionality
> > > mainly of text related Unix tools via vim.
> > 
> > Install Cygwin on windows and install Mintty from googlecode, use 
> > Mintty as your terminal emulator and Cygwin/bash as your shell, use the 
> > vim provided by Cygwin.
> > 
> > Then you'll feel at home on Windows.
> > 
> > 
> > That is what I would like to install on every Windows computer.
> > 
> 
> As I tried to explain with my broken English, I am not allowed to 
> install anything on my Windows-PC.
> Sorry...
> The only tool I have is: Vim.

Not to discount other suggestions (using glob()/etc. within Vim), but 
it's probably worth your while to find a workaround.  Vim's 
not-the-kitchen-sink philosophy[1] probably prevents it from being the 
swiss army knife you seem to be looking for.

Cygwin was the first thing I found that made Windows tolerable.  I 
believe (but am not certain) it's installable to a USB thumb drive, if 
that's an option.  (CoLinux is my current preference for using Linux 
under Windows, but that's far less likely to work under security 
restrictions).  I know MinGW is installable as such, but don't know if 
it provides the range of utilities you're seeking.

I've not tried Mintty, so I can't compare, but last time I was using 
Windows (a while ago), I liked Console2[2] as a cmd.exe replacement.

-- 
Best,
Ben H

[1] see: :help design-not
[2] http://console.sf.net/

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: Doing Unix on Windows

2010-04-22 Thread Dan Wierenga
On Thu, Apr 22, 2010 at 8:53 AM,   wrote:
>
> As I tried to explain with my broken English, I am not allowed to
> install anything on my Windows-PC.
> Sorry...
> The only tool I have is: Vim.

I'm not sure if having a Microsoft-supplied package will get around
your limitation of not being able to install things, but Microsoft has
had Unix tools for some time now:
http://technet.microsoft.com/en-us/library/cc779522%28WS.10%29.aspx
In the Control Panel, it's under "Turn Windows Features on or off" or
something similar.

Alternately, XP/Vista/Win7 versions of Windows can run PowerShell
(also under "Windows Features" on Vista), and it's installed natively
on Windows 7.  PowerShell is still missing some features of the
unix-land shells, but it is WAY better than plain old cmd.exe.  At the
minimum it supports command aliases and user-defined functions, which
goes a long way towards making life more tolerable.

HTH,
Dan

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: regex for a range that has a given number?

2010-04-22 Thread LuKreme
On 22-Apr-2010, at 10:14, Peng Yu wrote:
> 
> I frequently need to search for citations in papers by citation
> numbers.
> 
> For exmaple, something like [7] [2-8] [2,4,8-10] in the maintext
> represent what articles that are listed in the bibliography are cited.
> Now, I want to search for where it cites citation number 7 in the
> maintext (in this example, it is cited the three places in the
> maintext).
> 
> But I don't see a very general way to search for such citation. I
> suppect this may not be done by regex for every cases. But I'm not
> sure. Do anybody have a good solution?

Why can't you search for \[7\]

Or am I missing something. is 2-8 also valid for 7? If so, I think you are out 
of luck for regex.

-- 
Hello Diane, I'm Bucky Goldstein


-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: regex for a range that has a given number?

2010-04-22 Thread Peng Yu


On Apr 22, 1:25 pm, LuKreme  wrote:
> On 22-Apr-2010, at 10:14, Peng Yu wrote:
>
>
>
> > I frequently need to search for citations in papers by citation
> > numbers.
>
> > For exmaple, something like [7] [2-8] [2,4,8-10] in the maintext
> > represent what articles that are listed in the bibliography are cited.
> > Now, I want to search for where it cites citation number 7 in the
> > maintext (in this example, it is cited the three places in the
> > maintext).
>
> > But I don't see a very general way to search for such citation. I
> > suppect this may not be done by regex for every cases. But I'm not
> > sure. Do anybody have a good solution?
>
> Why can't you search for \[7\]
>
> Or am I missing something. is 2-8 also valid for 7? If so, I think you are 
> out of luck for regex.

2-8 is also valid for 7.

Is there anything that are more powerful than regex available in vim
that can handle this case?

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: regex for a range that has a given number?

2010-04-22 Thread Ben Fritz


On Apr 22, 11:14 am, Peng  Yu  wrote:
> I frequently need to search for citations in papers by citation
> numbers.
>
> For exmaple, something like [7] [2-8] [2,4,8-10] in the maintext
> represent what articles that are listed in the bibliography are cited.
> Now, I want to search for where it cites citation number 7 in the
> maintext (in this example, it is cited the three places in the
> maintext).
>
> But I don't see a very general way to search for such citation. I
> suppect this may not be done by regex for every cases. But I'm not
> sure. Do anybody have a good solution?
>

You can do it with a regex, but it won't be pretty, and it will
require some scripting if you want to automatically generate the
pattern in the general case.

For the number 7 specifically, I think this pattern will work (if I
correctly deciphered what you want to match):

\v%(\[|,)\zs%(7|[1-6]-%([7-9]|\d{2,}))

This should match anywhere that 7:
* is explicitly listed in the citation
* is contained within a range of numbers in the citation

It assumes you only have the number 7 immediately following a comma
within a citation.

Explanation:
\v -- very magic, to simplify the regex
%( -- start a group (without a backreference for minor speed gain) so
we can use '|' on part of the pattern
\[|, -- match either an opening brace or a comma
) -- close the first group
\zs -- not really needed, but adjusts highlighting to only cover the
numbers instead of also highlighting the opening bracket or comma
%( -- start another group so we can use '|' again
7 -- match a 7 that occurs by itself or as the first number in a range
[1-6]- -- match ranges that start with a number less than 7
%([7-9]|\d{2,}) -- match the final part of a range, that ends in
either a single digit with value greater than or equal to 7, or a 2-
digit number (which is always greater than 7)

Obviously this will need some tweaking for any citation number other
than seven. If you need to search for a 2-digit number it will take a
more effort but still should be possible with regex (it could get very
long however). Doing it in this way will result in very ugly regular
expressions that will probably be easy to get wrong unless you script
the construction of the regex.

A better approach might be to define a function that searches for a
citation using a simple regex like \[[^]*]\] with the search()
function. You can then use getline() to grab the line to parse out in
your function to determine whether the citation contains your number.
If it does not, you can call search() again until you find one that
does, or until you reach the end of the file.

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: regex for a range that has a given number?

2010-04-22 Thread Tim Chase

On 04/22/2010 03:37 PM, Peng Yu wrote:

For exmaple, something like [7] [2-8] [2,4,8-10] in the
maintext represent what articles that are listed in the
bibliography are cited. Now, I want to search for where it
cites citation number 7 in the maintext (in this example,
it is cited the three places in the maintext).


Or am I missing something. is 2-8 also valid for 7? If so, I
think you are out of luck for regex.


2-8 is also valid for 7.

Is there anything that are more powerful than regex available
in vim that can handle this case?


Not that I know of.  To tackle the problem, I'd likely
create a search-function that looks for matches of the form

  /\[\(\%(\d\+\%(-\d\+\)\=,\)*\%(\d\+\%(-\d\+\)\=\)]\)/

which should find all things that look like footnotes in
your text.  Then split them on the comma, returning a list
of either pages or page-ranges, then if any of them have a
"-" in them, check if the target value is within that range,
otherwise just compare for equality.  If you don't find any
match within the split-list, continue searching to the next
match of the above pattern.  The pseduo-code (untested)
would look something like

  function! FootSearch(fn)
let re='\[\(\%(\d\+\%(-\d\+\)\=,\)*\%(\d\+\%(-\d\+\)\=\)]\)'
let newmatch=searchpos(re, 's')
let initialmatch=newmatch
while newmatch != [0,0]
  let [r,c]=newmatch
  " m = the contents of the match
  " with the "[" and "]" stripped off
  " using the "[1:-2]"
  let m=matchstr(getline(r)[c:], re)[1:-2]
  for bit in split(m, ',')
" deal with any comma-separated list
" of pages or ranges
if bit=~'.*-.*'
  " if it's a page-range
  " pull the start/end
  let [st, end]=split(bit, '-')
  if st <= fn && fn <= end
" we're between the pages in that range
return
  endif
else
  if bit == fn
" it's an exact match
" might want do strip leading zeros
" from bit in case you search for "4"
" and the text contains [04]
return
  endif
endif
  endfor
  " if we've not returned by now,
  " this footnote doesn't match
  " so find the next and keep going
  let newmatch=searchpos(re, 's')
  if newmatch == initialmatch
" we've found the first match again
" so we've likely looped around
" and we've not returned yet
" so prevent an infinite loop
break
  endif
  let [r,c]=newmatch
endwhile
  endfunction

Any bugs are yours to keep ;-)  But that's the general idea I'd use.

-tim




--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: Doing Unix on Windows

2010-04-22 Thread meino . cramer
Benjamin R. Haskell  [10-04-22 19:56]:
> On Thu, 22 Apr 2010, meino.cra...@gmx.de wrote:
> 
> > pansz  [10-04-22 17:16]:
> > > 
> > > meino.cra...@gmx.de 写道:
> > > >Hi,
> > > > at home I am using Vim on Linux.
> > > > at work I am using Vim on Windows.
> > > > I am a Unixxer...
> > > > At work I am not allowed all that nice gimmicks like
> > > > grep, find, sed etc. which were ported to windows also  due to 
> > > >security reasons.
> > > > I would like to get back some of that functionality
> > > > mainly of text related Unix tools via vim.
> > > 
> > > Install Cygwin on windows and install Mintty from googlecode, use 
> > > Mintty as your terminal emulator and Cygwin/bash as your shell, use the 
> > > vim provided by Cygwin.
> > > 
> > > Then you'll feel at home on Windows.
> > > 
> > > 
> > > That is what I would like to install on every Windows computer.
> > > 
> > 
> > As I tried to explain with my broken English, I am not allowed to 
> > install anything on my Windows-PC.
> > Sorry...
> > The only tool I have is: Vim.
> 
> Not to discount other suggestions (using glob()/etc. within Vim), but 
> it's probably worth your while to find a workaround.  Vim's 
> not-the-kitchen-sink philosophy[1] probably prevents it from being the 
> swiss army knife you seem to be looking for.
> 
> Cygwin was the first thing I found that made Windows tolerable.  I 
> believe (but am not certain) it's installable to a USB thumb drive, if 
> that's an option.  (CoLinux is my current preference for using Linux 
> under Windows, but that's far less likely to work under security 
> restrictions).  I know MinGW is installable as such, but don't know if 
> it provides the range of utilities you're seeking.
> 
> I've not tried Mintty, so I can't compare, but last time I was using 
> Windows (a while ago), I liked Console2[2] as a cmd.exe replacement.
> 
> -- 
> Best,
> Ben H
> 
> [1] see: :help design-not
> [2] http://console.sf.net/
> 

To emphasis the security related things in "installing" something on
the Windows PC at work and "doing something, which is no installation
but results in something, which works like that":

We  (the workers) are even not allowed to carry any USB-stick or
other storage devices with us. Same goes for mobile phones with
cameras and so on.

Or in other words: Executing anything else than what is already
installed is FORBIDDEN -- otherwise I get fired.

I /have to/ rely on what I have : VIM.


> -- 
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
> 
> Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en
> 

-- 
Please don't send me any Word- or Powerpoint-Attachments
unless it's absolutely neccessary. - Send simply Text.
See http://www.gnu.org/philosophy/no-word-attachments.html
In a world without fences and walls nobody needs gates and windows.

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


RE: Doing Unix on Windows

2010-04-22 Thread Brent Saunders


-Original Message-
From: vim_use@googlegroups.com [mailto:vim_...@googlegroups.com] On Behalf Of 
meino.cra...@gmx.de
Sent: Thursday, April 22, 2010 5:13 PM
To: vim_use@googlegroups.com
Subject: Re: Doing Unix on Windows

Benjamin R. Haskell  [10-04-22 19:56]:
> On Thu, 22 Apr 2010, meino.cra...@gmx.de wrote:
> 
> > pansz  [10-04-22 17:16]:
> > > 
> > > meino.cra...@gmx.de 写道:
> > > >Hi,
> > > > at home I am using Vim on Linux.
> > > > at work I am using Vim on Windows.
> > > > I am a Unixxer...
> > > > At work I am not allowed all that nice gimmicks like
> > > > grep, find, sed etc. which were ported to windows also  due to 
> > > >security reasons.
> > > > I would like to get back some of that functionality
> > > > mainly of text related Unix tools via vim.
> > > 
> > > Install Cygwin on windows and install Mintty from googlecode, use 
> > > Mintty as your terminal emulator and Cygwin/bash as your shell, use the 
> > > vim provided by Cygwin.
> > > 
> > > Then you'll feel at home on Windows.
> > > 
> > > 
> > > That is what I would like to install on every Windows computer.
> > > 
> > 
> > As I tried to explain with my broken English, I am not allowed to 
> > install anything on my Windows-PC.
> > Sorry...
> > The only tool I have is: Vim.
> 
> Not to discount other suggestions (using glob()/etc. within Vim), but 
> it's probably worth your while to find a workaround.  Vim's 
> not-the-kitchen-sink philosophy[1] probably prevents it from being the 
> swiss army knife you seem to be looking for.
> 
> Cygwin was the first thing I found that made Windows tolerable.  I 
> believe (but am not certain) it's installable to a USB thumb drive, if 
> that's an option.  (CoLinux is my current preference for using Linux 
> under Windows, but that's far less likely to work under security 
> restrictions).  I know MinGW is installable as such, but don't know if 
> it provides the range of utilities you're seeking.
> 
> I've not tried Mintty, so I can't compare, but last time I was using 
> Windows (a while ago), I liked Console2[2] as a cmd.exe replacement.
> 
> -- 
> Best,
> Ben H
> 
> [1] see: :help design-not
> [2] http://console.sf.net/
> 

To emphasis the security related things in "installing" something on
the Windows PC at work and "doing something, which is no installation
but results in something, which works like that":

We  (the workers) are even not allowed to carry any USB-stick or
other storage devices with us. Same goes for mobile phones with
cameras and so on.

Or in other words: Executing anything else than what is already
installed is FORBIDDEN -- otherwise I get fired.

I /have to/ rely on what I have : VIM.


> -- 
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
> 
> Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en
> 
Here's something I used from a perl script.You can call something like this 
from a bat file.  But this snippet has the basics of how to use vim in line 
mode from the command line.  It may get you where you want.
`c:\\vim\\vim63\\vim -e -s -c "g\/^ttl\$\/d" -c "\%s\/^ttl\/\/" -c "g\/\^\$\/d" 
-c "\%s\/.\/\\L\&\/g" -c "\%\!sort" -c "\%\!uniq" -c "\%\!aspell -l" -c "wq" 
badlist.txt`;

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: Doing Unix on Windows

2010-04-22 Thread Ben Fritz


On Apr 22, 7:13 pm, meino.cra...@gmx.de wrote:
>
> Or in other words: Executing anything else than what is already
> installed is FORBIDDEN -- otherwise I get fired.
>
> I /have to/ rely on what I have : VIM.
>

With a policy that restrictive...count yourself lucky that you even
get to use Vim on Windows. Frankly it surprises me :-)

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: regex for a range that has a given number?

2010-04-22 Thread Christian Brabandt
Hi Tim!

On Do, 22 Apr 2010, Tim Chase wrote:

> Not that I know of.  To tackle the problem, I'd likely
> create a search-function that looks for matches of the form

That's what I'd have done to solve this problem.

>   function! FootSearch(fn)
> let re='\[\(\%(\d\+\%(-\d\+\)\=,\)*\%(\d\+\%(-\d\+\)\=\)]\)'
> let newmatch=searchpos(re, 's')
> let initialmatch=newmatch
> while newmatch != [0,0]
>   let [r,c]=newmatch
>   " m = the contents of the match
>   " with the "[" and "]" stripped off
>   " using the "[1:-2]"
>   let m=matchstr(getline(r)[c:], re)[1:-2]
>   for bit in split(m, ',')
> " deal with any comma-separated list
> " of pages or ranges
> if bit=~'.*-.*'
>   " if it's a page-range
>   " pull the start/end
>   let [st, end]=split(bit, '-')
>   if st <= fn && fn <= end
> " we're between the pages in that range
> return
>   endif
> else
>   if bit == fn
> " it's an exact match
> " might want do strip leading zeros
> " from bit in case you search for "4"
> " and the text contains [04]
> return
>   endif
> endif
>   endfor
>   " if we've not returned by now,
>   " this footnote doesn't match
>   " so find the next and keep going
>   let newmatch=searchpos(re, 's')
>   if newmatch == initialmatch
> " we've found the first match again
> " so we've likely looped around
> " and we've not returned yet
> " so prevent an infinite loop
> break
>   endif
>   let [r,c]=newmatch
> endwhile
>   endfunction

Oh, you already provided a solution. Then I don't need to spend time on 
that one.

>
> Any bugs are yours to keep ;-)  

This is one I noticed:
:s/\%(fu.*\)\@ But that's the general idea I'd use.

Mine was similar.

regards,
Christian

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en


Re: A question about the usage of cscope ?

2010-04-22 Thread robert song
that's cool, thank you very much.

2010/4/22 Christian Brabandt :
> On Thu, April 22, 2010 9:21 am, robert song wrote:
>> If I search for a string in the source code,
>> by typing :cs f t foo
>> then a list of the results will be shown, but I can't search quickly
>> in the list, but watch line by line to find the one I search for.
>> Is there any tip that help to solve the problem?
>> For example, save the list to buffer?
>
> See :h 'csqf' and :h csqf and possibly :h quickfix
>
> regards,
> Christian
>
>
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en
>

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php