Re: How to get the number of occurances of a search pattern ?

2007-03-29 Thread Wolfgang Schmidt

   Hi,

to count the number of matches, see

:help count-items

Hope this helps

   Wolfgang

MM wrote:

When I do a search using / ,?,* or # how do I determine the number of
matches of search pattern in the current buffer ?

Thanks




Re: Get date and filename as plain text

2007-03-15 Thread Wolfgang Schmidt

   Hi,

I don't know about the filename part, but you could insert a date with 
the following mapping:


inoremap @date C-R=strftime(%d.%m.%Y)CR

Cheers,

   Wolfgang

Eric Leenman wrote:

Hi,

Is it possible to make an inoremap that inserts the date as text and 
the filename as text?


For example:

inoremap @date   {insert_date_as_text()}
inoremap @filename   {insert_filename_as_text()}


Rgds,
Eric

_
Get a FREE Web site, company branded e-mail and more from Microsoft 
Office Live! http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/




Re: run make! from subdirs

2007-02-20 Thread Wolfgang Schmidt

   Hi Ilia,

to me it looks like you always want to compile using the Makefile in 
ProjectDir. I don't know if this helps much, but I would recommend to 
open the Makefile in one buffer, then hide it:


:hid

and do your source editing. When you want to compile your files, use

:sb Maktab

to switch to the Makefile in a split window and start

:make

as usual. After compilation, you can hide the Makefile again and 
continue working.


An alternate way would be to change your make command as James proposed.

Or you could write a macro to change to the directory and run make

:help macro

Cheers,

   Wolfgang

Someone noticed that if I add this line into .vimrc:
autocmd BufEnter * :cd %:p:h

I'll be able to run :make and vim will automatically look at the directory
where currently opened file is located for Makefile.

But if I have directory structure like this:

[d]ProjectDir
  main.cpp
  Makefile
  [dir]SrcDir1
 file1.cpp
  [dir]SrcDir2
 file2.cpp

this command do not work. Makefile is located in root ProjectDir and if I
open for example file1.cpp from SrcDir1, vim can't locate Makefile and I
HAVE TO SWITCH TO ANOTHER BUFFER which contains some source from
ProjectDir in order to compile program...

Is there any opportunity to solve this situation. I have to recompile
project very often while debug sessions, and there is really huge dir
hierarchy...  
  




alt gr on german keyboard not working in gvim

2007-02-13 Thread Wolfgang Schmidt


   Hi vimmers,

I just compiled an actual vim/gvim (7.0) on linux (2.4.21-226-smp4G). In 
the console, everything is fine, I can use ALTGR-q to get an atsign on a 
german keyboard. When I'm in gvim and try the same, I just get a 'q' 
typed, seems like ALT GR is deactivated in gvim (same for ALTGR-7, 
normally '{') etc.


Can anyone give me a hint what might be the problem?

Thanx in advance

   Wolfgang



Re: How to diff in gvim

2007-02-13 Thread Wolfgang Schmidt

Eric Leenman wrote:

Hi,

I'm trying to diff two files in (portable) gvim
I have two files opened in two vertical windows.
(Kind of Winmerge screen setup)

When I type :diff  I get the error
E97: Can not create diffs


Why is that?

When I type :verbose
I dont get more info


   Hi,

try

:help E97

to get a list of possible reasons and solutions.

Cheers,

   Wolfgang


Re: How to override $HOME on Windows NT/XP?

2006-11-22 Thread Wolfgang Schmidt

   Hi,

to me it's no clear what you mean by prevent Vim from going to my Home 
directory. I'm using Vim on windows, too, but he never asked me for a 
HOME directory. Instead, the _vimrc file is kept in $VIMRUNTIME, which 
by default on XP is C:\Programme\Vim\vim70. Therefore, all you have to 
do is to put

your _vimrc there and all should work fine.

Cheers

   Wolfgang


Paul Stone wrote:

I know this is a bizarre request.  I would like to prevent Vim from
going to my Home directory.  The reason is that my IT department has
mapped my home directory to a laggy network drive with a login script.
I can't override the Windows environment variables which set up the
home directory, because the login script overrides my settings.

I can set up the environment in a DOS box, but I like to be able to
invoke Vim by using the edit with vim context menu item.

Any advice on how to workaround this issue?  Vim keeps grinding to a
halt while waiting for a response from the network drive, so I have to
solve this.

If there's no way to workaround it in Vim, then I will contact IT to
see if they can change my login script.

Best Regards,
Paul Stone




Re: search in files

2006-10-31 Thread Wolfgang Schmidt

bolow wrote:

hi all,
 I have a question:how to search a keyword in all files in a current
dir(include the sub dirs) by vim? thanks for your reply:)

   Hi,

what you're looking for is grep/vimgrep, I think.

grep uses an external grep command, vimgrep is a built-in functionality 
of vim.


To search the current directory for all files containing String aString:

:vimgrep /aString/ *

To do the same search including sub dirs:

:vimgrep /aString/ **/*

This uses the ** (starstart)-wildcard to match subdirectories.

For more information try
:help grep
:help vimgrep
:help starstar


Kind regards
   Wolfgang


Re: Paren highlighting and jump to

2006-10-12 Thread Wolfgang Schmidt

Meino Christian Cramer wrote:

Hi,

 (I am vim 7.0.131 on the console only on a recent gentoo Linux system)

 I looked into :h paren but found nothing appropiate...

 Currently my vim highlights matching parens. This is nice as long
 the corrosponding paren are on different lines or at least not
 grouped like this:

 (x)

 Additionally my cursor changes its color depending on whether it is
 in insert or normal mode.

 When the cursor is at the position of the x in the above example,
 confusion arises, since so much color on one place is...confusing.

 I would like to make the cursor to jump shortly to the other paren
 as long there is nothing typed in.
  

   Hi,

I thing what you're looking for is showmatch (:h showmatch), you can set 
it with


:set showmatch
or
:set sm

Cheers,

   Wolfgang



autoread

2006-09-07 Thread Wolfgang Schmidt
  
  Hi,


I want to use vim to watch the output of another program (logfile, 
compilation output, ...). I want to have something like the 
functionality of the unix tail command, that is, if something new is 
written to the file, I want the buffer to get updated. I know I can 
reload the file manually with :e, but I want it to be done 
automatically. I tried the autoread option (:set ar), but I still have 
to reload the buffer by hand, the buffer does not get updated 
automatically. Could anybody tell me, how autoread is supposed to work?


Thanx in advance

   Wolfgang


Re: autoread

2006-09-07 Thread Wolfgang Schmidt

Yakov Lerner wrote:

On 9/7/06, Wolfgang Schmidt [EMAIL PROTECTED] wrote:


   Hi,

I want to use vim to watch the output of another program (logfile,
compilation output, ...). I want to have something like the
functionality of the unix tail command, that is, if something new is
written to the file, I want the buffer to get updated. I know I can
reload the file manually with :e, but I want it to be done
automatically. I tried the autoread option (:set ar), but I still have
to reload the buffer by hand, the buffer does not get updated
automatically. Could anybody tell me, how autoread is supposed to work?


Autoread is something different and wont help you.
Try this:
   set nolz | while 1 | e | redraw | $ | sleep 1 | endw
which does approximately what you need. Cancel by Ctrl-C.
Or bundle this line into mapping and/or custom functions.

Yakov
  

As I get it, the autoread option is used to make vim reread the file 
when a user event (keystroke etc) occurs;
it's not a continuous process of checking and updating, but has to be 
triggered by the user. Your solution does periodical checking and 
updating at the cost of blocking vim for other tasks, which in my case 
is ok, for a tail command also does block the used shell.


Thanx to  you and Tony for your answers, this helped me a lot

   Wolfgang


E505, File is write-protected

2006-08-21 Thread Wolfgang Schmidt


   Hi vimmers,

when I try to write (:w) a certain buffer, I get E505 (~ file XXX is 
write-protected, override with w!).
The protection seems to be set by Vim, not the OS (WinXP). So I looked 
for the readonly option value,
but it's set to noreadonly. I also checked write, which is set to 
write. Nevertheless, everytime I try to
:w the file, I get this E505 dialog. Any hints? I'm running Gvim 7.0 on 
Win XP)


Thanx in advance

   Wolfgang


Re: E505, File is write-protected

2006-08-21 Thread Wolfgang Schmidt

Wolfgang Schmidt wrote:
when I try to write (:w) a certain buffer, I get E505 (~ file XXX is 
write-protected, override with w!).
The protection seems to be set by Vim, not the OS (WinXP). So I looked 
for the readonly option value,
but it's set to noreadonly. I also checked write, which is set to 
write. Nevertheless, everytime I try to
:w the file, I get this E505 dialog. Any hints? I'm running Gvim 7.0 on 
Win XP)



are you able to write the file with :w!? If not, the file might be
opened exclusively or with write-access denied by another program.

Regards,
Jürgen

  


With :w! the file can be written, so this can't be the problem.

Thanks, though ...

   Wolfgang





Re: E505, File is write-protected - Problem solved

2006-08-21 Thread Wolfgang Schmidt
I don't know. I'm sending this to the list so someone else may answer. 
(Please use Reply to all next time.) 

Best regards,
Tony.


I got rid of the problem finally now by - rebooting. I looks like 
another nice  feature of this obscure NTFS file system.


Thanx Tony and Jürgen for your proposals,

   Wolfgang

  


non-greedy pattern matching

2006-08-16 Thread Wolfgang Schmidt

   Hi vimmers,

I'm trying to do a regexp replacement. My original line is

ignore MATCH1 ignore_again MATCH2

I want to match MATCH1 and MATCH2, so here's my trial:

s/^ignore \(.*\{-}\) .*\{-} \(.*\)/matched:\1,\2/gc

I tried to use \{-} to make the .* match non-greedy, but I get E62 and 
E476.


Of course there are other ways to match the capitalized words, like \S 
or something similar,

but I'd like to know how to use non-greedy matching here.

Thanx in advance

   Wolfgang


Re: Problem doing diffs using win 2000

2006-07-03 Thread Wolfgang Schmidt

Yegappan Lakshmanan wrote:

Do you have the 'diffexpr' set in your .vimrc file?

:verbose set diffexpr?

- Yegappan

   Hi,

yes, it's set to MyDiff(), which is defined in _vimrc as

set diffexpr=MyDiff()
function MyDiff()
 let opt = '-a --binary '
 if diffopt =~ 'icase' | let opt = opt . '-i ' | endif
 if diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
 let arg1 = v:fname_in
 if arg1 =~ ' ' | let arg1 = '' . arg1 . '' | endif
 let arg2 = v:fname_new
 if arg2 =~ ' ' | let arg2 = '' . arg2 . '' | endif
 let arg3 = v:fname_out
 if arg3 =~ ' ' | let arg3 = '' . arg3 . '' | endif
 silent execute '!C:\Programme\Vim\vim70\diff ' . opt . arg1 . ' ' . 
arg2 . '  ' . arg3

endfunction

This work's fine for WinXP, but not for Win2k

Cheers,

   Wolfgang


Correction: Problem doing diffs using win 2000

2006-07-03 Thread Wolfgang Schmidt

   Hi,

after re-examination of the problem I found the diff functionaliy now 
working on Win2k, still don't know what caused the problem.
Anyway, diff'ing does work under Win2k, sorry for the confusion and 
thanks to those who tried to help.


Sorry,

   Wolfgang

Wolfgang Schmidt wrote:


   Hi,

I just installed gvim70 (from the self-extracting exe) on WIN 2K 
system. Everything seems to work, exept the diff functionality.

If I do a diff, e.g.

C:\Programme\Vimvim _vimrc -d _vimrc.bak

I get

2 Dateien zum Editieren
Das angegebene Programm kann nicht ausgeführt werden.

E97: Kann keine Differenz erstellen

so Vim complains, that the diff program can't be executed. But the 
diff program is present (C:\Programme\Vim\vim70\diff.exe) and it works 
(I tried it manually from the commandline).


Maybe there's a problem with diff under win2K? I've used the same 
installer executable to install gvim70 on some Win XP machines, and I 
did not have any problems with diff.


Thanx in advance

   Wolfgang




Problem doing diffs using win 2000

2006-06-30 Thread Wolfgang Schmidt


   Hi,

I just installed gvim70 (from the self-extracting exe) on WIN 2K system. 
Everything seems to work, exept the diff functionality.

If I do a diff, e.g.

C:\Programme\Vimvim _vimrc -d _vimrc.bak

I get

2 Dateien zum Editieren
Das angegebene Programm kann nicht ausgeführt werden.

E97: Kann keine Differenz erstellen

so Vim complains, that the diff program can't be executed. But the diff 
program is present (C:\Programme\Vim\vim70\diff.exe) and it works (I 
tried it manually from the commandline).


Maybe there's a problem with diff under win2K? I've used the same 
installer executable to install gvim70 on some Win XP machines, and I 
did not have any problems with diff.


Thanx in advance

   Wolfgang