RE: autocmd bug?

2007-03-27 Thread Michael Wookey
> But your command gave me an idea -- the following should work
> 
>   au FileType *.* exe substitute(expand(''),
>   \  '^\(.*\)\.\(.*\)$',
>   \  'doau FileType \1 | doau FileType \2',
>   \  '')

Thankyou - this is the behaviour I was expecting.


Re: disappearing color

2007-03-27 Thread Jason Keen

On 3/27/07, Greg Novack <[EMAIL PROTECTED]> wrote:

Thus spake Jason Keen [03/27/07 @ 16.10.46 -0400]:
> On 3/27/07, Greg Novack <[EMAIL PROTECTED]> wrote:
> >Vim Aficionados,
> >
> >I run console vim.  My normal colorscheme, as set in the .vimrc, is
> >`Default' with backround set to dark.  This has always had the consequence
> >that the line at the bottom of the screen that says `--INSERT--' whenever
> >I'm in that mode is displayed in magenta.
> >
> >Last night, this changed to display in white.  I did not mess with the
> >terminal emulator's colors.  I *did* begin playing around with commands
> >that change the syntax coloring while I'm in the middle of a document,
> >e.g.,
> >
> >:hi LineNr ctermfg=green
> >
> >But my understanding was that such "live" commands are temporary; when I
> >exited vim, they are lost, and a restart of vim would bring the usual
> >colors I named in the .vimrc.  So I'm wondering (a) what happened to my
> >purple mode notice?, and (b) did whatever happened to it happen because of
> >my piecemeal coloring commands?
> >
> >Many thanks,
> >
> >GMN
> >
> I tried to replicate this, but when I set my colorscheme to default,
> it had white text in the status line.  Seems like a weird situation,
> and smells like it is environment-specific.
> Good luck!

Ye Gods, I've found out where I got fooled.  The magenta did indeed come from 
my terminal, as I'd assigned any bold text to magenta.  Because the 
---INSERT--- is bold and was therefore always a different color (magenta) from 
the body text of my docs (white), I thought that

:hi normal ctermfg=white

would not apply to the ---INSERT---.  Lo and behold, I had exactly that command 
in my .vimrc.  I thought it couldn't possibly be the culprit, hence my post.  
Doh!

Many thanks, from a semi-newbie.

GMN


You're welcome, from another semi-newbie.


Re: a simple mapping

2007-03-27 Thread LandSurveyor
The quotes are definitely not the way to go.  I've tried

vim -u test_vimrc.vim

where test_vimrc.vim contained merely your first line (slightly
modified):

nnoremap  :set nobackup

and it worked fine.  I don't know whether it has to do with
switching over to nnoremap (I prefer to be explicit when I
specify a mapping) or some other plugin that is overriding your
desired settings.  You  might try

:scriptnames

to see what scripts are being loaded (and may want to investigate
them in the event that one of them is rebinding ).

-tim

Thanks for your gnawing on this.  As it turns out, and I had responded thusly 
to another good soul, the problem was merely my method of evoking my intended 
change:

   source ~/.vimrc

That DIDN'T work!

What I had done (to begin) was borrow an already valid keymapping:

map   :nohlsearch 

and copied it to use as a template (it worked once...oughta work again)

the change became (and it ultimately worked),

   map  :set nobkackup   #bTW,  becomes  when :map

my problem was, the shell command  was the wrong way to go-it 
created problems.  As soon as I logged out and back in, everything worked fine.


Re: disappearing color

2007-03-27 Thread Greg Novack
Thus spake Jason Keen [03/27/07 @ 16.10.46 -0400]:
> On 3/27/07, Greg Novack <[EMAIL PROTECTED]> wrote:
> >Vim Aficionados,
> >
> >I run console vim.  My normal colorscheme, as set in the .vimrc, is 
> >`Default' with backround set to dark.  This has always had the consequence 
> >that the line at the bottom of the screen that says `--INSERT--' whenever 
> >I'm in that mode is displayed in magenta.
> >
> >Last night, this changed to display in white.  I did not mess with the 
> >terminal emulator's colors.  I *did* begin playing around with commands 
> >that change the syntax coloring while I'm in the middle of a document, 
> >e.g.,
> >
> >:hi LineNr ctermfg=green
> >
> >But my understanding was that such "live" commands are temporary; when I 
> >exited vim, they are lost, and a restart of vim would bring the usual 
> >colors I named in the .vimrc.  So I'm wondering (a) what happened to my 
> >purple mode notice?, and (b) did whatever happened to it happen because of 
> >my piecemeal coloring commands?
> >
> >Many thanks,
> >
> >GMN
> >
> I tried to replicate this, but when I set my colorscheme to default,
> it had white text in the status line.  Seems like a weird situation,
> and smells like it is environment-specific.
> Good luck!

Ye Gods, I've found out where I got fooled.  The magenta did indeed come from 
my terminal, as I'd assigned any bold text to magenta.  Because the 
---INSERT--- is bold and was therefore always a different color (magenta) from 
the body text of my docs (white), I thought that

:hi normal ctermfg=white

would not apply to the ---INSERT---.  Lo and behold, I had exactly that command 
in my .vimrc.  I thought it couldn't possibly be the culprit, hence my post.  
Doh!  

Many thanks, from a semi-newbie.

GMN


Re: autocmd bug?

2007-03-27 Thread Jürgen Krämer

Hi,

A.J.Mechelynck wrote:
> Jürgen Krämer wrote:
> [...]
>> Nice idea (esp. the recursion), but alas it's not that simple, because
>> the pattern only accepts wildcards (not regular expressions) and if it
>> did, the subpatterns would probably not be recognized in the command.
>> But your command gave me an idea -- the following should work
>>
>>   au FileType *.* exe substitute(expand(''),
>>   \  '^\(.*\)\.\(.*\)$',
>>   \  'doau FileType \1 | doau FileType \2',
>>   \  '')
>>> ('cindent' is set by the indent/c.vim plugin).
>> Regards,
>> Jürgen
>>
> 
> additional question: does ":doau" work in an autocommand or does it require a 
> "nested" flag somewhere?

>From the example at ":help doautocmd" it seems that an additional
"nested" is not needed. I also tested it by defining the following
autocommand:

  au FileType * echo expand('')

The result of executing

  setf c.doxygen

was

  c.doxygen
  c
  doxygen

So I'd say "nested" is not needed.

Regards,
Jürgen

-- 
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)


Re: disappearing color

2007-03-27 Thread Jason Keen

On 3/27/07, Greg Novack <[EMAIL PROTECTED]> wrote:

Vim Aficionados,

I run console vim.  My normal colorscheme, as set in the .vimrc, is `Default' 
with backround set to dark.  This has always had the consequence that the line 
at the bottom of the screen that says `--INSERT--' whenever I'm in that mode is 
displayed in magenta.

Last night, this changed to display in white.  I did not mess with the terminal 
emulator's colors.  I *did* begin playing around with commands that change the 
syntax coloring while I'm in the middle of a document, e.g.,

:hi LineNr ctermfg=green

But my understanding was that such "live" commands are temporary; when I exited 
vim, they are lost, and a restart of vim would bring the usual colors I named in the 
.vimrc.  So I'm wondering (a) what happened to my purple mode notice?, and (b) did 
whatever happened to it happen because of my piecemeal coloring commands?

Many thanks,

GMN


I tried to replicate this, but when I set my colorscheme to default,
it had white text in the status line.  Seems like a weird situation,
and smells like it is environment-specific.
Good luck!


Re: two questions , map and scroll

2007-03-27 Thread shawn bright

thanks for all the help, gents
doing just what i want now.

sk

On 3/27/07, fREW <[EMAIL PROTECTED]> wrote:

On 3/27/07, Andy Wokula <[EMAIL PROTECTED]> wrote:
> shawn bright schrieb:
> > lo there,
> >
> > i have two quick questions.
> > first, is there a way i can scroll text under the cursor ( so that the
> > cursor stays on the same place in the terminal, but the text scrolls
> > anyway )
> > i just think that would be really cool.
>
> Without mappings:
>
> " keep cursor in same column
> :set nostartofline
> " global, also has influence on other commands
>
> " how many lines to scroll
> :set scroll=1
> " local to window
>
> Then use Ctrl-D and Ctrl-U.  A count changes the value of 'scroll'.
>
> Don't miss the help:
> :h 'sol
> :h 'scr
>
> --
> Regards,
> Andy
>
> EOM
>

What I would do for the rails stuff (and what I actually do for
Template Toolkit w/ perl) is use abbreviations.  For example:

:ab RLS <% %>^]hhi
:ab RL= <%= %>^]hhi

That way when you type RLS(space) it will put you inside the brackets
automatically.  Note: the ^] is a literal, so to type it you need to
do .

--
-fREW



Re: two questions , map and scroll

2007-03-27 Thread fREW

On 3/27/07, Andy Wokula <[EMAIL PROTECTED]> wrote:

shawn bright schrieb:
> lo there,
>
> i have two quick questions.
> first, is there a way i can scroll text under the cursor ( so that the
> cursor stays on the same place in the terminal, but the text scrolls
> anyway )
> i just think that would be really cool.

Without mappings:

" keep cursor in same column
:set nostartofline
" global, also has influence on other commands

" how many lines to scroll
:set scroll=1
" local to window

Then use Ctrl-D and Ctrl-U.  A count changes the value of 'scroll'.

Don't miss the help:
:h 'sol
:h 'scr

--
Regards,
Andy

EOM



What I would do for the rails stuff (and what I actually do for
Template Toolkit w/ perl) is use abbreviations.  For example:

:ab RLS <% %>^]hhi
:ab RL= <%= %>^]hhi

That way when you type RLS(space) it will put you inside the brackets
automatically.  Note: the ^] is a literal, so to type it you need to
do .

--
-fREW


disappearing color

2007-03-27 Thread Greg Novack
Vim Aficionados,

I run console vim.  My normal colorscheme, as set in the .vimrc, is `Default' 
with backround set to dark.  This has always had the consequence that the line 
at the bottom of the screen that says `--INSERT--' whenever I'm in that mode is 
displayed in magenta.

Last night, this changed to display in white.  I did not mess with the terminal 
emulator's colors.  I *did* begin playing around with commands that change the 
syntax coloring while I'm in the middle of a document, e.g.,

:hi LineNr ctermfg=green

But my understanding was that such "live" commands are temporary; when I exited 
vim, they are lost, and a restart of vim would bring the usual colors I named 
in the .vimrc.  So I'm wondering (a) what happened to my purple mode notice?, 
and (b) did whatever happened to it happen because of my piecemeal coloring 
commands?

Many thanks,

GMN


Re: two questions , map and scroll

2007-03-27 Thread Andy Wokula

shawn bright schrieb:

lo there,

i have two quick questions.
first, is there a way i can scroll text under the cursor ( so that the
cursor stays on the same place in the terminal, but the text scrolls
anyway )
i just think that would be really cool.


Without mappings:

   " keep cursor in same column
   :set nostartofline
   " global, also has influence on other commands

   " how many lines to scroll
   :set scroll=1
   " local to window

Then use Ctrl-D and Ctrl-U.  A count changes the value of 'scroll'.

Don't miss the help:
   :h 'sol
   :h 'scr

--
Regards,
Andy

EOM


Re: Search & Replace in VIM Script

2007-03-27 Thread A.J.Mechelynck

oskar wrote:

Hello

that works if I execute the command in the normal mode in VIM. Now my next
question is:

How can I use the %s command from a VIM script in order to modify a given
line of a file?

Thank you


To change "foo" to "bar" everywhere at line 1234:

1234s/foo/bar/g

(i.e., in a script the initial : is not needed.)

see
:help :s
:help range
:help script


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
142. You dream about creating the world's greatest web site.


Re: Search & Replace in VIM Script

2007-03-27 Thread Tim Chase
>> I think you may be looking for the zero-width atoms in the
>> "\%#c" family, so you might search for something like
>> 
>> :%s/\%33cABCD/FGHI/
> 
> that works if I execute the command in the normal mode in VIM.
> Now my next question is:
> 
> How can I use the %s command from a VIM script in order to
> modify a given line of a file?

For the most part, any Ex command (beginning with a colon) also
functions as a vimscript command.  Thus, you can simply omit the
colon in a vimscript:

function! foo()
1,10s/\%33cABCD/FGHI/
endfunction

will replace ABCD (at position 33) with FGHI from lines 1-10.
You don't even *have* to omit the colon, but it's easier to read
scripts without it.  The line-numbers are any range, so you can use

%s/...

for the whole file, or

1/int main/,$s/...

to do the replacements from "int main" through the end of the
file.  Or what have you.  All sorts of power/flexibility
available with Ex commands. :)

-tim

PS:  Please, as a courtesy, don't top-post...it makes it hard to
follow.  I've changed my reply to incorporate inline commenting.








Re: two questions , map and scroll (oops)

2007-03-27 Thread A.J.Mechelynck

A.J.Mechelynck wrote:

shawn bright wrote:

lo there,

i have two quick questions.
first, is there a way i can scroll text under the cursor ( so that the
cursor stays on the same place in the terminal, but the text scrolls
anyway )
i just think that would be really cool.


see thread "Keep cursor fixed when scrolling the mouse" started 
yesterday at 20:24 UTC by "Some user" in this same list.




second. i do a lot of rails stuff, so i open and close a lot of rails 
tags.

<% stuff here %>
<%= output stuff here %>

does someone have a suggestion to automate some of this ?

thanks



It all depends what you want to do. To add <%%> at the cursor and place 
the cursor in the middle:


:inoremap  %%>

To duplicate the current line and open insert in between

:nnoremap  yypO

To duplicate the visual selection linewise and place the cursor at the 
start of the copy:


:vnoremap  :yank  '>put  norm '


Oops!

:vnoremap  :yank  '>put  '>+1



etc.


Best regards,
Tony.




Re: two questions , map and scroll

2007-03-27 Thread Yakov Lerner

On 3/27/07, shawn bright <[EMAIL PROTECTED]> wrote:

lo there,

i have two quick questions.
first, is there a way i can scroll text under the cursor ( so that the
cursor stays on the same place in the terminal, but the text scrolls
anyway )
i just think that would be really cool.


To have cursor fixed in the middle line of the screen:
   :set so=999

You can have your cursor fixed at some other line of the screen.
But this is external plugin (for example on 2/3 from the top of the screen):

  http://www.vim.org/scripts/script.php?script_id=1649
 scrollfix.vim -- keep cursor at fixed visual line of window

Yakov


Re: Search & Replace in VIM Script

2007-03-27 Thread oskar

Hello

that works if I execute the command in the normal mode in VIM. Now my next
question is:

How can I use the %s command from a VIM script in order to modify a given
line of a file?

Thank you


Tim Chase-2 wrote:
> 
>> I have a vim script which I want to use to search & replace a
>> part out of a given line. The fields in the line are based on
>> field length and the field I want to change starts at position
>> 33 and ends after 4 charachter.
>> 
>> A regex search is not appropriet, as the string I am looking
>> for may occur in another field in the same line but shoult not
>> be changed here. I already tried substitute() and had a look
>> to the normal command :s with a subset, but none of them
>> worked for me.
> 
> 
> I think you may be looking for the zero-width atoms in the "\%#c"
> family, so you might search for something like
> 
>   :%s/\%33cABCD/FGHI/
> 
> (there may be an off-by-one error here, so you might have to
> adjust that 33 to be 32 or 34 to land on your proper column).
> This would replace any "ABCD" starting at column 33 with "FGHI"
> 
> There are a family of these:
> 
>   :help /\%c
>   :help /\%v
>   :help /\%l
> 
> They're all right next to each other in the help and allow you to
> do exactly what you describe, searching for a given item at a
> given column offset (there are subtle differences between the %c
> and %v varieties).
> 
> Hope this helps,
> 
> -tim
> 
> 
> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Search---Replace-in-VIM-Script-tf3473037.html#a9696683
Sent from the Vim - General mailing list archive at Nabble.com.



Re: two questions , map and scroll

2007-03-27 Thread A.J.Mechelynck

shawn bright wrote:

lo there,

i have two quick questions.
first, is there a way i can scroll text under the cursor ( so that the
cursor stays on the same place in the terminal, but the text scrolls
anyway )
i just think that would be really cool.


see thread "Keep cursor fixed when scrolling the mouse" started yesterday at 
20:24 UTC by "Some user" in this same list.




second. i do a lot of rails stuff, so i open and close a lot of rails tags.
<% stuff here %>
<%= output stuff here %>

does someone have a suggestion to automate some of this ?

thanks



It all depends what you want to do. To add <%%> at the cursor and place the 
cursor in the middle:


:inoremap  %%>

To duplicate the current line and open insert in between

:nnoremap  yypO

To duplicate the visual selection linewise and place the cursor at the start 
of the copy:


:vnoremap  :yank  '>put  norm '

etc.


Best regards,
Tony.
--
Ah say, son, you're about as sharp as a bowlin' ball.


Re: two questions , map and scroll

2007-03-27 Thread Tim Chase
> first, is there a way i can scroll text under the cursor ( so that the
> cursor stays on the same place in the terminal, but the text scrolls
> anyway )
> i just think that would be really cool.

If you want the cursor to stay in the middle of the screen, you
can set your 'scrolloff' setting to some ridiculously high value
such as

:set scrolloff=

If, however, you want to pan the text under your cursor, you have
to do a bit more work to intercept the various commands that
would move as you desire.  Something like

:nnoremap j j
:nnoremap k k

might do the trick.  Fine-grained control when doing larger jumps
 becomes problematic merely for having to intercept them all and
get vim to do something intelligent for each one.  Not
impossible, but perhaps more trouble than it's worth.

> second. i do a lot of rails stuff, so i open and close a lot of rails tags.
> <% stuff here %>
> <%= output stuff here %>
> 
> does someone have a suggestion to automate some of this ?

There are some plugins/scripts on the vim.org site that ease
working with tagged-style documents (html, xml, wml, docbook,
etc) so you might try searching there for keywords like "tag" and
"close".  Or you could do some work with insert-mode mappings and
abbreviations.

Just a few ideas,

-tim




two questions , map and scroll

2007-03-27 Thread shawn bright

lo there,

i have two quick questions.
first, is there a way i can scroll text under the cursor ( so that the
cursor stays on the same place in the terminal, but the text scrolls
anyway )
i just think that would be really cool.

second. i do a lot of rails stuff, so i open and close a lot of rails tags.
<% stuff here %>
<%= output stuff here %>

does someone have a suggestion to automate some of this ?

thanks


Re: Search & Replace in VIM Script

2007-03-27 Thread Jean-Rene David
* oskar [2007.03.27 11:25]:
> I have a vim script which I want to use to
> search & replace a part out of a given line. The
> fields in the line are based on field length and
> the field I want to change starts at position 33
> and ends after 4 charachter.

Sample data and the result you expect would make
things so much easier...

This will match characters in columns 33-36:

/\%33c

:h /\%c

-- 
JR


RE: Error format and quickfix

2007-03-27 Thread Christophe Dupre
> > Here is what I get when I do copen.
> > 
> > || ccsc main.c +FH +P +DC +LO +EA +STDOUT I+="..\Includes"
> > || >>> Warning 201
"C:\Project\Test\OnlineMS\Firmware\Source\rs232.c"
> > Line 48(1,1): Assignment inside relational expression
> > || *** Error 12 "C:\Project\Test\OnlineMS\Firmware\Source\main.c"
Line
> > 97(3,4): Undefined identifier   j
> > ||   1 Errors,  1 Warnings.
> > [...]

> > || >>> Warning 201
"C:\Project\Test\OnlineMS\Firmware\Source\rs232.c"
> > Line 48(1,1): Assignment inside relational expression
> > || *** Error 12 "C:\Project\Test\OnlineMS\Firmware\Source\main.c"
Line
> > 97(3,4): Undefined identifier   j
> > 
> > Here is what I think I should define.
> > \|\|\ \>\>\>\ %t\ %n\ %f\ Line\ %lXXX%m \|\|\ \*\*\*\ %t\ %n\ %f\ 
> > Line\ %lXXX%m Can you spot anything wrong here?

> Yes. 

> The || characters at the beginning of the line are added by vim on
lines it doesn't recognize. You needn't parse them > > because they are
not part of you compiler's output.

> > How do I deal with the (1,1), and the (3,4)?

> That depends what they mean. 
It's means the column number: beginning and end.
So the first digit can be replaced by %c, what about the second one? How
can I represent it? I don't really need it actually, can I just omit it?

Thanks,

Christophe


Re: autocmd bug?

2007-03-27 Thread A.J.Mechelynck

Jürgen Krämer wrote:
[...]

Nice idea (esp. the recursion), but alas it's not that simple, because
the pattern only accepts wildcards (not regular expressions) and if it
did, the subpatterns would probably not be recognized in the command.
But your command gave me an idea -- the following should work

  au FileType *.* exe substitute(expand(''),
  \  '^\(.*\)\.\(.*\)$',
  \  'doau FileType \1 | doau FileType \2',
  \  '')

('cindent' is set by the indent/c.vim plugin).


Regards,
Jürgen



additional question: does ":doau" work in an autocommand or does it require a 
"nested" flag somewhere?


Best regards,
Tony.
--
It was one of those perfect summer days -- the sun was shining, a
breeze was blowing, the birds were singing, and the lawn mower was
broken ...
-- James Dent


Re: Search & Replace in VIM Script

2007-03-27 Thread Albie Janse van Rensburg

oskar wrote:

Hello

After searching the Internet for 3 hours and not finding an answer here the
question:

I have a vim script which I want to use to search & replace a part out of a
given line. The fields in the line are based on field length and the field I
want to change starts at position 33 and ends after 4 charachter.

A regex search is not appropriet, as the string I am looking for may occur
in another field in the same line but shoult not be changed here. I already
tried substitute() and had a look to the normal command :s with a subset,
but none of them worked for me.

Any suggestions?
  

Try this command:

:s/^\(.\{32\}\)PATT/\1REPL/

the above command is a substitute (:s) that executes on the current 
line, and matches the first 32 characters on the line followed by PATT 
(replace with your desired pattern), and then replaces it with whatever 
the first 32 characters was and the replacement string (REPL).  The rest 
of the line is left unchanged.


Hope that helps

--
Albie Janse van Rensburg


Re: Search & Replace in VIM Script

2007-03-27 Thread Charles E Campbell Jr

oskar wrote:


I have a vim script which I want to use to search & replace a part out of a
given line. The fields in the line are based on field length and the field I
want to change starts at position 33 and ends after 4th character.

A regex search is not appropriate, as the string I am looking for may occur
in another field in the same line but should not be changed here. I already
tried substitute() and had a look to the normal command :s with a subset,
but none of them worked for me.
 



There are other ways, but it seems the easiest is to use a regexp in a 
substitute:


[range]s/\%33c.\{4}/-NEW/

(pick your range, of course)

Regards,
Chip Campbell


Re: Search & Replace in VIM Script

2007-03-27 Thread Tim Chase
> I have a vim script which I want to use to search & replace a
> part out of a given line. The fields in the line are based on
> field length and the field I want to change starts at position
> 33 and ends after 4 charachter.
> 
> A regex search is not appropriet, as the string I am looking
> for may occur in another field in the same line but shoult not
> be changed here. I already tried substitute() and had a look
> to the normal command :s with a subset, but none of them
> worked for me.


I think you may be looking for the zero-width atoms in the "\%#c"
family, so you might search for something like

:%s/\%33cABCD/FGHI/

(there may be an off-by-one error here, so you might have to
adjust that 33 to be 32 or 34 to land on your proper column).
This would replace any "ABCD" starting at column 33 with "FGHI"

There are a family of these:

:help /\%c
:help /\%v
:help /\%l

They're all right next to each other in the help and allow you to
do exactly what you describe, searching for a given item at a
given column offset (there are subtle differences between the %c
and %v varieties).

Hope this helps,

-tim






Re: Deleting some lines from a log file

2007-03-27 Thread Jean-Rene David
* Eddine [2007.03.27 09:45]:
> ENTRY
> 
> 184
> 185  
> **;
> 186  *   PGMs Complexes   1 : enable - O : disable
>   *;
> 187  
> **;123
> 
> 188
> 189   %include "&pgm.MainComplex.sas"; ** Macro principale
> Base et Queries **;
> NOTE: %INCLUDE (level 1) file E:\IFM
>  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas
> is file E:\IFM
>  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas.
> 
> 269 
> +**;
> MPRINT(MAINCOMPLEX):
> **;
> 
> RESULT :
> 
> NOTE: %INCLUDE (level 1) file E:\IFM
>  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas
> is file E:\IFM
>  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas.
> 
> **;
> 
> (for a try :%s/^[0-9]*/TEST/ didn't work).

You are close. The problem is that this pattern
will match *every* line, since you accept "zero or
more" digits at the beginning of the line.

Try:

:%s/^[0-9]\+/TEST/

Using \+ instead of * in the pattern will match
"one or more" instead of "zero or more".

Then to also match lines that begin with MPRINT:

:%s/^\([0-9]\+\|MPRINT\)/TEST/

Then to delete them (make sure you undo the
previous substitution...):

:g/^\([0-9]\+\|MPRINT\)/d

HTH,

-- 
JR


Re: Deleting some lines from a log file

2007-03-27 Thread Brian McKee

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 27-Mar-07, at 9:01 AM, Eddine wrote:


Hi

I have to clean up a log file.
I want to exclude/delete lines that start with a number or "MPRINT" :

{snippage}

I first tyred to identify all numbers at a beginning of a line, but
for instance when doing a substitution I cannot find the good regex
(for a try :%s/^[0-9]*/TEST/ didn't work).

Can you tell me how I have to do to delete those lines beginning by
numbers or MPRINT from my file ?


You were close.  Try

:g/^\d\|^\(MPRINT\)/d

Using :g/regex/d to delete whole lines that contain /regex/ I find a  
lot easier than

   :%s/regex.*\n//  which accomplishes the same thing

Using \d instead of [0-9] I think is easier too.

For what it's worth,  I find it really helpful to play with regexes  
just using /regex/ and looking at the resulting highlighted areas.
Once you get just what you want you just do a :%s// or :g// and it  
fills in the last used regex.


For example - try your regex of /^[0-9]*/ then change it to /^[0-9].*/

HTH
Brian



-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (Darwin)
Comment: Verify this email or encrypt your email for free - see gnupg.org

iD8DBQFGCSTjGnOmb9xIQHQRAtLeAJ992I/JzEP+5bvAMkEoECJqBAMXGQCgmbm0
7ON4v88jNJ/rIi0/hKfOonA=
=5pm2
-END PGP SIGNATURE-


A new voting item

2007-03-27 Thread Bram Moolenaar

Upon request I have added one more item to vote on:

Add an indication what text was changed since editing started
(change bar or diff)

If you are sponsoring Vim or are a registered Vim users you can adjust
your votes at http://www.vim.org/sponsor/vote.php .

-- 
It is illegal to take more than three sips of beer at a time while standing.
[real standing law in Texas, United States of America]

 /// 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: autocmd bug?

2007-03-27 Thread Jürgen Krämer

Hi,

A.J.Mechelynck wrote:
> Jürgen Krämer wrote:
> [...]
>> the FileType event is only fired once with the exact filetype you
>> specified in your set command, so you must additionally define the
>> following autocommand:
>>
>>   autocmd FileType c.doxygen setlocal cindent number cursorline
> 
> If that is true, doesn't it defeat the purpose of setting the filetype with a 
> dot?

I'm not sure -- at least it seems to be a little bit inconsistent to
me, because ":help 'filetype'" explicitly mentions filetype plugins and
syntax files:

| When a dot appears in the value then this separates two filetype
| names.  Example:
|   /* vim: set filetype=c.doxygen : */ ~
| This will use the "c" filetype first, then the "doxygen" filetype.
| This works both for filetype plugins and for syntax files.  More than
| one dot may appear.

So, moving the ":setlocal" commands from the autocommand to a filetype
plugin would work, but there seem to be a lot of people that want to
keep their settings in one single place -- namely ~/.vimrc -- to make
it simpler to exchange them between multiple installations.

> Or should we add something like (untested)
> 
>:au Filetype \(w*\).\(\S*\) exe "doau FileType \1" | exe "doau FileType \2"
> 
> ?

Nice idea (esp. the recursion), but alas it's not that simple, because
the pattern only accepts wildcards (not regular expressions) and if it
did, the subpatterns would probably not be recognized in the command.
But your command gave me an idea -- the following should work

  au FileType *.* exe substitute(expand(''),
  \  '^\(.*\)\.\(.*\)$',
  \  'doau FileType \1 | doau FileType \2',
  \  '')
> 
> ('cindent' is set by the indent/c.vim plugin).

Regards,
Jürgen

-- 
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)


Re: Deleting some lines from a log file

2007-03-27 Thread Eddine

Afterwards It seems so simple with your help
Many thanks  to you Tom, Tim and Vim community !

Eddine

2007/3/27, Tom Whittock <[EMAIL PROTECTED]>:

:g/^MPRINT/d
:g/^\d\+/d

should do more or less what you want.

Cheers.



Re: Deleting some lines from a log file

2007-03-27 Thread Tim Chase
> Can you tell me how I have to do to delete those lines beginning by
> numbers or MPRINT from my file ?

Though I'm not sure I followed your examples, if this is all you
want, the following should do what your above-summary describes:

  :g/^\(\d\|MPRINT\)/d

That breaks down as

:g/.../ on every line matching the "..." pattern
d   delete that line

The "..." of "^\(\d\|MPRINT\)" means "at the beginning of the
line (^) match either a digit (\d) or (\|) the text MPRINT" (the
"\(" and "\)" are for grouping control as I never remember
whether the beginning-of-line associates with a branch or not, so
I tend to be explicit).

Hope this helps,

-tim




Re: autocmd bug?

2007-03-27 Thread A.J.Mechelynck

Jürgen Krämer wrote:
[...]

the FileType event is only fired once with the exact filetype you
specified in your set command, so you must additionally define the
following autocommand:

  autocmd FileType c.doxygen setlocal cindent number cursorline

Regards,
Jürgen



If that is true, doesn't it defeat the purpose of setting the filetype with a 
dot?

Or should we add something like (untested)

  :au Filetype \(w*\).\(\S*\) exe "doau FileType \1" | exe "doau FileType \2"

?

('cindent' is set by the indent/c.vim plugin).


Best regards,
Tony.
--
If God had meant for us to be naked, we would have been born that way.


Re: Keep cursor fixed when scrolling with mouse

2007-03-27 Thread A.J.Mechelynck

Some user wrote:

Hello,

I'm using gVim on Windows and like it so far. There is one minor annoyance:
when I scroll with the mouse wheel (I'm trying to use only keyboard but
it'll take me a lot of time trying to break habit of using mouse to scroll),
the cursor moves with the screen. Is there a setting I can set that will
allow the cursor to remain fixed at one position when scrolling with the
mouse wheen/scrollbar?

Thanks,


" normal and visual
:noremap  33j
:noremap  33k
" not command-line
:cunmap 
:cunmap 
" insert mode
:inoremap  33j
:inoremap  33k

This maps the mouse wheel to scroll the display and move the cursor, so that 
the cursor appears immobile on-screen (possibly barring edge conditions near 
the top and bottom of the file).


Best regards,
Tony.
--
Sharks are as tough as those football fans who take their shirts off
during games in Chicago in January, only more intelligent.
-- Dave Barry, "Sex and the Single Amoeba: What Every
   Teen Should Know"


Search & Replace in VIM Script

2007-03-27 Thread oskar

Hello

After searching the Internet for 3 hours and not finding an answer here the
question:

I have a vim script which I want to use to search & replace a part out of a
given line. The fields in the line are based on field length and the field I
want to change starts at position 33 and ends after 4 charachter.

A regex search is not appropriet, as the string I am looking for may occur
in another field in the same line but shoult not be changed here. I already
tried substitute() and had a look to the normal command :s with a subset,
but none of them worked for me.

Any suggestions?
-- 
View this message in context: 
http://www.nabble.com/Search---Replace-in-VIM-Script-tf3473037.html#a9692208
Sent from the Vim - General mailing list archive at Nabble.com.



Re: Deleting some lines from a log file

2007-03-27 Thread Tom Whittock

:g/^MPRINT/d
:g/^\d\+/d

should do more or less what you want.

Cheers.

On 27/03/07, Eddine <[EMAIL PROTECTED]> wrote:

Hi

I have to clean up a log file.
I want to exclude/delete lines that start with a number or "MPRINT" :


ENTRY

184
185  
**;
186  *   PGMs Complexes   1 : enable - O : disable
   *;
187  
**;123

188
189   %include "&pgm.MainComplex.sas"; ** Macro principale
Base et Queries **;
NOTE: %INCLUDE (level 1) file E:\IFM
  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas
is file E:\IFM
  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas.

269 
+**;
MPRINT(MAINCOMPLEX):
**;



RESULT :

NOTE: %INCLUDE (level 1) file E:\IFM
  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas
is file E:\IFM
  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas.

**;


I first tyred to identify all numbers at a beginning of a line, but
for instance when doing a substitution I cannot find the good regex
(for a try :%s/^[0-9]*/TEST/ didn't work).

Can you tell me how I have to do to delete those lines beginning by
numbers or MPRINT from my file ?

Many thanks.

Eddine.



Re: search for one word and exclude another

2007-03-27 Thread A.J.Mechelynck

Kamaraju S Kusumanchi wrote:

Hi
I need to search for a word 'condition' (without quotes) and exclude
hits containing 'condition number'.

On a shell I can do

grep -sir condition *F90 | grep -v 'condition number'

How do I do it the vim way?

thanks
raju



Try

:g/\\%(\s\+number\>)[EMAIL PROTECTED]/p

Explanation of the pattern

\<  begin of word (don't match "precondition")
condition   matches itself
\>  end of word (don't match "conditional")
\%( start subpattern
\s\+any number of whitespace (at least one)
number  matches itself
\>  end of word ("condition numbering" is different)
\)  end subpattern
[EMAIL PROTECTED] subpattern must NOT match

For :g/pattern/p see ":help :g"


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
140. You'd rather catch a score on the web than watch the game as
 it is being played on tv.


Deleting some lines from a log file

2007-03-27 Thread Eddine

Hi

I have to clean up a log file.
I want to exclude/delete lines that start with a number or "MPRINT" :


ENTRY

184
185  
**;
186  *   PGMs Complexes   1 : enable - O : disable
  *;
187  
**;123

188
189   %include "&pgm.MainComplex.sas"; ** Macro principale
Base et Queries **;
NOTE: %INCLUDE (level 1) file E:\IFM
 2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas
is file E:\IFM
 2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas.

269 
+**;
MPRINT(MAINCOMPLEX):
**;



RESULT :

NOTE: %INCLUDE (level 1) file E:\IFM
 2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas
is file E:\IFM
 2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas.

**;


I first tyred to identify all numbers at a beginning of a line, but
for instance when doing a substitution I cannot find the good regex
(for a try :%s/^[0-9]*/TEST/ didn't work).

Can you tell me how I have to do to delete those lines beginning by
numbers or MPRINT from my file ?

Many thanks.

Eddine.


Re: a simple mapping

2007-03-27 Thread Tim Chase
> Reading over my original question, I realize that it was
> awfully obtuse and confusing.  The 'nohlsearch' line is the
> one that is already in my .vimrc and works.  I yanked/put it
> to the next line down to use it as a template, modifing it to:
> 
> map  :set nobackup 
> 
> that's the one that doesn't work (the 
> part-obviously-works with my original line).
> 
> I did notice that the highlighting recognized the word 'set'
> as a command, but did not recognize 'nobackup', which remained
> white (black?).  Thus, I tried:
> 
> map  ":set nobackup" 
> 
> with no better luck.  Sorry for creating the confusion.


The quotes are definitely not the way to go.  I've tried

vim -u test_vimrc.vim

where test_vimrc.vim contained merely your first line (slightly
modified):

nnoremap  :set nobackup

and it worked fine.  I don't know whether it has to do with
switching over to nnoremap (I prefer to be explicit when I
specify a mapping) or some other plugin that is overriding your
desired settings.  You  might try

:scriptnames

to see what scripts are being loaded (and may want to investigate
them in the event that one of them is rebinding ).

-tim




Re: Error format and quickfix

2007-03-27 Thread Jean-Rene David
* Christophe Dupre [2007.03.27 07:15]:
> Here is what I get when I do copen.
> 
> || ccsc main.c +FH +P +DC +LO +EA +STDOUT I+="..\Includes"
> || >>> Warning 201 "C:\Project\Test\OnlineMS\Firmware\Source\rs232.c"
> Line 48(1,1): Assignment inside relational expression
> || *** Error 12 "C:\Project\Test\OnlineMS\Firmware\Source\main.c" Line
> 97(3,4): Undefined identifier   j
> ||   1 Errors,  1 Warnings.
> [...]

To avoid mistakes, it would be easier if you
provided your *compiler's* output, not what you
see in the quickfix window. For example, in the
above, one has to deduce that the line wrap has
been added by vim, but it may as well have been in
the compiler's output. Another reason will be
apparent below.

> I guess what I need to define is the format for
> only these 2 lines (correct me if I'm wrong) ,
> and can ignore the rest.

Yes, I think this is correct.

> || >>> Warning 201 "C:\Project\Test\OnlineMS\Firmware\Source\rs232.c"
> Line 48(1,1): Assignment inside relational expression
> || *** Error 12 "C:\Project\Test\OnlineMS\Firmware\Source\main.c" Line
> 97(3,4): Undefined identifier   j
> 
> Here is what I think I should define.
> \|\|\ \>\>\>\ %t\ %n\ %f\ Line\ %lXXX%m
> \|\|\ \*\*\*\ %t\ %n\ %f\ Line\ %lXXX%m
> Can you spot anything wrong here?

Yes. 

The || characters at the beginning of the line are
added by vim on lines it doesn't recognize. You
needn't parse them because they are not part of
you compiler's output.

> How do I deal with the (1,1), and the (3,4)?

That depends what they mean. 

-- 
JR


Re: Customizing vim: How to change the char before commands

2007-03-27 Thread A.J.Mechelynck

Tobia wrote:

A.J.Mechelynck wrote:

fREW wrote:

So is there a way we could swap the ; and : keys?  I hardly ever
use ";" but it would be nice to still have it available as :

The following lines in your vimrc should do it:

noremap ; :
noremap : ;


Except that you still have to type : in some places, such as in
"Hit ENTER or type command to continue" prompts.


Tobia



Is that such a big deal? You could hit the space bar to cancel the prompt, and 
then the ; key would start an ex-command.


Best regards,
Tony.
--
"An anthropologist at Tulane has just come back from a field trip to
New Guinea with reports of a tribe so primitive that they have Tide but
not new Tide with lemon-fresh Borax."
-- David Letterman


Re: python omnicompletion with Python 2.5

2007-03-27 Thread Christian Ebert
* Christian Ebert on Tuesday, March 27, 2007 at 01:15:20 +0200:
> I did a few experiments.
> 
> As I compile with --disable-darwin, I build a Vim.app (that's how
> it's called on the Mac) for testing, and there things get even
> more confusing with a newer Python in /usr/local, as it uses the
> new Python in /usr/local as C-API but links against the old
> Python shipped by Apple in
> /System/Library/Frameworks/Python.framework/Versions/2.3
> 
> Then I made my usual build with --disable-darwin and called
> ./src/vim
> meaning vim in the build directory. And! everything worked.
> Still, after make install, vim in /usr/local/bin showed the same
> errors.



> Apparently "make install" strips something from the executable.

Solved/worked around by, eg:

--- a/src/Makefile  Tue Mar 27 12:08:55 2007 +0200
+++ b/src/Makefile  Tue Mar 27 12:52:35 2007 +0200
@@ -998,7 +998,7 @@ INSTALL_DATA_R  = cp -r
 INSTALL_DATA_R = cp -r
 
 ### Program to run on installed binary
-#STRIP = strip
+STRIP = strip -x
 
 ### Permissions for binaries  {{{1
 BINMOD = 755



-- 
Vim plugin to paste current GNU Screen buffer in (almost) any mode:



Re: Can you create file dependend fold markers

2007-03-27 Thread Tom Whittock

:g/^process\s\+\w\+/,/^end process/fold
Is process a special word?

process (CLK)


process is not a special word - regular expressions do not look like
regular programming languages. I would recommend reading up on vim
regular expressions. the reason why this particular match fails is
because of the parenthesis around the word. Adding (after \s\+ and an
extra ) after the end of the \w\+ should get a match is this
particular case, since the full text is matched, and \w only matches
'word' characters, not punctuation.


Error format and quickfix

2007-03-27 Thread Christophe Dupre
Hello,

I've been using Vim for a while now, and getting quite good at it, but
what I miss right now is to be able to compile and jump to the error.
I'm therefore trying to define the error format for my compiler. I'm
using CCS compiler; it's used to program PIC micro controller.

Here is what I get when I do copen.

|| ccsc main.c +FH +P +DC +LO +EA +STDOUT I+="..\Includes" 
|| >>> Warning 201 "C:\Project\Test\OnlineMS\Firmware\Source\rs232.c"
Line 48(1,1): Assignment inside relational expression
|| *** Error 12 "C:\Project\Test\OnlineMS\Firmware\Source\main.c" Line
97(3,4): Undefined identifier   j
||   1 Errors,  1 Warnings.
|| main.hex
|| 1 file(s) copied.
|| A duplicate file name exists, or the file
|| cannot be found.
|| A duplicate file name exists, or the file
|| cannot be found.
|| C:\Project\Test\OnlineMS\Firmware\Source\main.err
|| A duplicate file name exists, or the file
|| cannot be found.
|| A duplicate file name exists, or the file
|| cannot be found.
|| A duplicate file name exists, or the file
|| cannot be found.

I guess what I need to define is the format for only these 2 lines
(correct me if I'm wrong) , and can ignore the rest.
|| >>> Warning 201 "C:\Project\Test\OnlineMS\Firmware\Source\rs232.c"
Line 48(1,1): Assignment inside relational expression
|| *** Error 12 "C:\Project\Test\OnlineMS\Firmware\Source\main.c" Line
97(3,4): Undefined identifier   j

Here is what I think I should define.
\|\|\ \>\>\>\ %t\ %n\ %f\ Line\ %lXXX%m
\|\|\ \*\*\*\ %t\ %n\ %f\ Line\ %lXXX%m
Can you spot anything wrong here?

How do I deal with the (1,1), and the (3,4)? 

Thanks for your help,

Christophe


Re: building gvim on debian

2007-03-27 Thread Yakov Lerner

Thanks Tim and Brian.

The problem turned to be in our firewall, it suddenly started to block the bz2's
that 'apt-get update'. 'apt-get build-dep vim-gtk' command helped. me.

Regarding breezy and dapper -- together, yes, this is the sources.list
Mepis comed with by default; they are both enabled together.

Yakov