Re: minor feature request: let!

2006-07-13 Thread justin constantino

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


Justin Constantino wrote:

 Currently, if you try to assign a value to a variable with a different
 type, you get:

 E706: Variable type mismatch

 To make it work, you have to first unlet the variable, which is kind
 of annoying if the expression you are assigning references that
 variable.  For example, to split a string in-place, you have to do:

 let foo = one,two,three
 let temp = split(foo, ',')
 unlet foo
 let foo = temp
 unlet temp

 As a minor improvement, I think it would be nice if you could do:

 let foo = one,two,three
 let! foo = split(foo, ',')

Suppose someone asks you what the foo variable is for, what are you
going answer?

The point is: let the variable name reflect what it contains, don't
re-use the same variable for something else.  That way your code will be
a lot more readable.

 let fooline  = one,two,three
 let foowords = split(fooline, ',')



Fair enough, but in most of the cases where this came up, I never
really cared about the 'fooline' variable. It only existed as an
intermediate to 'foowords'.  My choices were either: 1) put everything
in one assignment, which can get long and messy and harder to read, or
2) split it into two assignments by declaring an extra 'foowords' that
I never really care about.  Reusing the variable makes sense to me in
this case, and this seemed like a harmless and logical addition, but I
guess you're the Bram.


Re: Gvim for KDE

2006-07-13 Thread Diwaker Gupta

i don't get it

vim compiles for me just fine -- suse linux 10.0, using KDE,
vim 7.0.35 -- am i missing something here?


I think he meant a Vim GUI that is based on KDE/Qt rather than GNOME/GTK.

Diwaker
--
Web/Blog/Gallery: http://floatingsun.net/blog


Re: question for charles (or anyone): netrw whacking t

2006-07-13 Thread Benji Fisher
On Wed, Jul 12, 2006 at 01:24:51PM -0400, Charles E Campbell Jr wrote:
 Benji Fisher wrote:
 
 I think I see the problem.  In $VIMRUNTIME/autoload/netrw.vim , in
 the function netrw#DirBrowse() , there are the lines
 
  if fo =~ '[ta]'
   set fo-=t
   set fo-=a
   echohl Warning
   echo '***warning*** directory browsing and formatoptions ta are 
   incompatible'
   echohl None
  endif
 
 (I am not sure that I ever get to see that warning message.)  I think
 that replacing :set with :setlocal will fix the problem.  Remember, when
 dealing with a local option, :set changes both the local value and the
 global default; :setlocal changes only the value...
 
 I think it should be
 
  :let l:spell = ...
  
 
 Actually, I don't want to use local settings; just obstinate, I guess!  
 What netrw v102h does
 (and its available at my website, 
 http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs
 as Network Oriented Reading, Writing, and Browsing) is save global 
 settings, make them
 netrw-friendly, do the browsing thing, restore the settings.

 In that case, use the g: prefix.  For example, try the following
experiment:

:set spell
:new
:setl spell!
:echo spell l:spell g:spell

I think you should get

0 0 1

(as I do).  So spell references the local value of the option, not the
global value.  Now, consider the lines

  let w:spellkeep = spell
  ...
  if exists(w:spellkeep)|let spell  = w:spellkeep   |unlet w:spellkeep|endif

in $VIMRUNTIME/autoload/netrw.vim .  The first sets w:spellkeep to the
local value, and the second sets the global value.

 Bottom line:  while testing the OP's problem before my original
post on this thread, I did find that options ended up being set in ways
I did not want nor expext, and

:verbose set spell?

told me that netrw was the culprit.

HTH --Benji Fisher


Re: How do I stop a mapping from looking like a mapping?

2006-07-13 Thread Yakov Lerner

On 7/13/06, Peter Hodge [EMAIL PROTECTED] wrote:

However, if I type anything beginning with 'for', the letters disappear
until I
type something that is not part of the mapping.  I understand this is
the
standard behaviour, but is there any way to change it so I can see
 what I am
typing?


Although there is no stardard option for imap to do this (make incompete
mapping visible; yes I'd find it seful, too), I found  a weird trick that
does what you want.
Does the following do what you want:
-
:imap h c-r=PrecedingChars(6) !=# 'foreac' ? 'h' : ExpandForeach() cr

function! ExpandForeach()  expansion of the foreach mapping
nb: 'foreac' is already there. So we don't need to repeat it
   return h() {\n}\Left
endfunction

function! PrecedingChars(n)
return n chars preceding cursor in rhs of :imap mapping
   return getline('.')[col('.')-1-a:n : col('.')-2]
endfunction
---

Explanation: this remaps 'h' character to check 6 preceding chars.
If 6 preceding chars are 'foreac', then it is expanded into your you
foreach-template. Otherwise, literas 'h' is inserted. Since this is
1-char-length mapping, there's no delay and no invisibilities.

If you wonder where is expansion (rhs) of your template, it's
inside function ExpandForeach(). The function PrecedingChars()
is generic and doesn't change when you change rhs of your template.

2.
If you find this too complex, and you don't want to
press space or tab after 'foreach' (supposedly because it
makes 8 chars instead of 7?) , then can I suggest either this simple weirdity:

:iab foreac foreach ...

(In which case, you get to type 'foreac' then space, which makes
total 7 characters not 8.), or this mapping

   :imap ctrl-Zf foreach 

which is economy of 5 chars on the lhs side. (You type ctrl-z then f)

Yakov


Re: matchit doesn't work for php

2006-07-13 Thread Pete Johns
On Thu, 2006-07-13 at 06:42:43 +0200, Cesar Romani sent:
In the following function the bracket at 3 doesn't match the
bracket at 17 And the bracket at 5 doesn't match the bracket at
8

I don't think matchit.vim is to blame here. I have tried your
code with VIM - Vi IMproved 7.0 (2006 May 7, compiled Jun 26 2006
20:24:17) with matchit.vim removed and it still misbehaves.

Somewhat surprisingly, though, matchparen.vim is highlighting the
correct braces!

I'm sorry I cannot provide a solution, but hopefully this will
point you in the right direction.


Best wishes;


--paj
-- 
Pete Johns   http://johnsy.com/
Contact Information  http://johnsy.com/contact/
Bothered   http://johnsy.com/20060709100906


pgpMJdEjnEt04.pgp
Description: PGP signature


Re: a question about subsitution....

2006-07-13 Thread Robert Cussons

Thanks Yakov,

that was the explanation I wanted.

Rob.

Yakov Lerner wrote:

On 7/12/06, Robert Cussons [EMAIL PROTECTED] wrote:


Thanks Max and Chip, I didn't realis that \ and \ were used to denote
the beginning and end of the word and therefore they could be used
separately, I always just thought of them as a way of getting an exact
match, which I suppose is almost the same thing, however, I still don't
understand why you can't exclusively mark the start of this string 
with \




Try /\*\word\
, it will work.

But /\\*
will never match, becuse \ requires alphabetic character after it.
When you put non-alphabetic char [*] to the right of \, \
will *NEVER* match. I know this is non-intuituve, but
this is how it works. \ requires alphabetic char to the right of it.
This is why \[*] never matches.

\ requires alphabetic char to the right of it. This is why
\\* never matches.

\ requires alphabetic char right after it. Thisis the reason
\\* never matches.

Yakov



--

Robert Cussons
Office SB3 3.163, Theory Group
Gesellschaft für Schwerionenforschung mbH (GSI)
Planckstraße 1
64291 Darmstadt
Germany.

Tel: +49 (0)6159 71 2754
E-mail: [EMAIL PROTECTED]



cindent problem

2006-07-13 Thread Jÿffffe9rÿfffff4me Douillard
Hello,

I have a problem when indenting C comments(cindent)
I would like to have (I must fit to my company's
coding rules):
/*
This is the comment
*/

But with cindent, I get : 
/*
This is the comment
*/

== My */ is at the same indent level as the body.

What should I set in gvim?

currently I use : 
set cino=c4  
setlocal comments=sO:*\ -,mO:*\ \
,exO:*/,sl:/*,mb:*,elx:*/,://


Thanks for your help

Jerome








___ 
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son 
interface révolutionnaire.
http://fr.mail.yahoo.com


script installation from remote url

2006-07-13 Thread Yakov Lerner

I realize that installing scripts from remote URLs
always have security considerations associated with it.

Still, my question is: Let's say that somebody I trust
published useful script (plugin) at some URL, like http://xyz.

Is there any command or script, supposedly bundled with vim (?)
that would *in one invocation* download script S from this URL
right into my ~/.vim/plugin ? Ideally:
   :InstallScript URL

If not, then what's the closest existing thing to such :InstallScript
functionality ?

Thanks
Yakov


ftplugin not detected

2006-07-13 Thread julien . r . nguyen
Hi everybody,

ViM does not detect my ada ftplugin file in $HOME/.vim/ftplugin/ada.vim,
though my runtimepath variable contains ~/.vim .
If I source the file manually, my stuff does work.
Has anyone an idea of what's wrong?

Regards,
Julien


This message and any attachments (the message) is
intended solely for the addressees and is confidential. 
If you receive this message in error, please delete it and 
immediately notify the sender. Any use not in accord with 
its purpose, any dissemination or disclosure, either whole 
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message. 
BNP PARIBAS (and its subsidiaries) shall (will) not 
therefore be liable for the message if modified. 

-

Ce message et toutes les pieces jointes (ci-apres le 
message) sont etablis a l'intention exclusive de ses 
destinataires et sont confidentiels. Si vous recevez ce 
message par erreur, merci de le detruire et d'en avertir 
immediatement l'expediteur. Toute utilisation de ce 
message non conforme a sa destination, toute diffusion 
ou toute publication, totale ou partielle, est interdite, sauf 
autorisation expresse. L'internet ne permettant pas 
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce 
message, dans l'hypothese ou il aurait ete modifie.



Re: ANN: VST 1.0 Finally

2006-07-13 Thread sgp
I installed per provided instructions (WinXP) but when I type :Vst I get a 
bunch of error messages, mostly undefined variables:

g:plinen_rez
g:paras_rez
g:ptype_rez
etc.

all of which are initialized in $VIM\vimfiles\autoload\vst\vst.vim but 
don't seem to be picked up when :Vst is executed.

:Vstm and :Vstfold work OK, it's just :Vst that doesn't.

What do I need to do to make it work? TIA 



Re: How do I stop a mapping from looking like a mapping?

2006-07-13 Thread Marc Weber
I'm even to lazy to type foreach. Thus I've defined mappings like this:
inoremap buffer m-fm-e foreachspace...
Makes total of 2 keys+ meta key. ;)

with this mapping
   opens the ftp plugin file with _mw appended
  map m-s-fm-s-tm-s-p :exec 'e 
~/.vim/ftplugin/'.filetype.'_mw.vim'cr
  and 
   inswerts  the inoremap beginning ..
  imap buffer m-im-m inoremapspacebufferspace
you can add additional mappings very quickly

Marc


Re: Awareness of python import semantics for [i, etc.?

2006-07-13 Thread Benji Fisher
On Wed, Jul 12, 2006 at 03:48:22PM -0700, John Reese wrote:
 So there's this handy [i command that, when filetype=c, displays the
 first line mentioning the identifier under the cursor, which will
 often be its definition.  The especially handy thing about it is that
 it knows about #include lines and will search through them as well
 when looking for the first match.  You can also put the cursor over
 the .h file between the quotes and hit gf, and if the path and
 suffixesadd options are set appropriately, it will jump you to the .h
 file.
 
 The point is, vim can be configured to know how to find C include
 files and use them in various ways.
 
 I was wondering if there was a way to get it to have a similar level
 of knowledge about Python modules.  In C,
 
  #include z.h
 will look for z.h in the current directory.  That's easy enough... the
 Python equivalent is something like
  import z
 
 But that actually just loads z.py from the current directory (or from
 a bunch of other possible places, including system library directories
 and directories listed in the PYTHONPATH environment variable) and
 puts the name z into your namespace, and if you want to refer to
 something defined in z.py, you qualify it:  z.someFunction().  A
 Python-aware [i would know that if I have the cursor on the
 someFunction in z.someFunction, then it needs to look for the word
 someFunction in z.py.
 
 There's also this from path import syntax:
  from a.b.c import z
 
 which might mean that relative to the current directory there's a file
 a/b/c/z.py that would need to be looked through if you used [i.
 
 So, anyway, this all seems very complicated, but I figured it wasn't
 entirely out of the question that something was supported or
 available, especially given the existence of the compiled-in Python
 scripting option.  Does anyone know of anything to let vim understand
 Python import syntax and use it for [i and similar commands?

 I am not sure if everything you want to do is possible or easy, but
I suggest you start here:

:help include-search
:help 'path'
:help 'include'
:help 'includeexpr'

See, for example, the ftplugin files for plaintex and tex.

HTH --Benji Fisher


Re: matchit doesn't work for php

2006-07-13 Thread Benji Fisher
On Thu, Jul 13, 2006 at 06:42:43AM +0200, Cesar Romani wrote:
  
 In the following function the bracket at 3 doesn't match the bracket at 17
 And the bracket at 5 doesn't match the bracket at 8
 
  1 ?php
  2   function test1($a,$b,$c,$d,$e,$f)
  3   {
  4 if($e=='hola')
  5 {
  6   if($f=='') $f='1000'; 
  7   $s='{'.$d.':'.$f.'}amigo'; 
  8 }
  9 else
 10 {
 11   $s='{'.$d.':'.$f.'}amiga'; 
 12 }
 13 $this-s=$s;
 14 $this-a=$a;
 15 $this-b=$b;
 16 $this-c=$c;
 17   }
 18 ?
 
 Many thanks in advance.
 
 Cesar

 The problem is that { is included in the 'matchpairs' option but
not in b:match_words.  The matchit script recognizes that { is a
matching character, but does not have a rule for it, so it defaults to
the built-in % matching behavior.  You can confirm this with

:normal! %

 The solution is to add '{:}' to b:match_words ; probably also '(:)'
and '[:]' while you are at it.  Also, I notice that ftplugin/php.vim
:source's ftplugin/html.vim and so inherits the HTML setting of
b:match_skip .  I think that PHP would do better with the default skip
behavior, so it should :unlet this variable.

 I am cc'ing the maintainer of ftplugin/php.vim .

HTH --Benji Fisher


Re: script installation from remote url

2006-07-13 Thread Benji Fisher
On Thu, Jul 13, 2006 at 09:26:16AM +, Yakov Lerner wrote:
 I realize that installing scripts from remote URLs
 always have security considerations associated with it.
 
 Still, my question is: Let's say that somebody I trust
 published useful script (plugin) at some URL, like http://xyz.
 
 Is there any command or script, supposedly bundled with vim (?)
 that would *in one invocation* download script S from this URL
 right into my ~/.vim/plugin ? Ideally:
:InstallScript URL
 
 If not, then what's the closest existing thing to such :InstallScript
 functionality ?
 
 Thanks
 Yakov

 Have a look at $VIMRUNTIME/autoload/spellfile.vim .  Since this is
already in an autoload file, maybe it should be rewritten to make it
more generic.

HTH --Benji Fisher


Re: script installation from remote url

2006-07-13 Thread Steve Hall
From: Yakov Lerner, Jul 13, 2006 5:26 AM

 I realize that installing scripts from remote URLs
 always have security considerations associated with it.

 Still, my question is: Let's say that somebody I trust
 published useful script (plugin) at some URL, like http://xyz.

 Is there any command or script, supposedly bundled with vim (?)
 that would *in one invocation* download script S from this URL
 right into my ~/.vim/plugin ? Ideally:
 :InstallScript URL

 If not, then what's the closest existing thing to such
 :InstallScript functionality ?

Not only is this possible, it is how Vim7 adds additional spellcheck
dictionaries if you do :set spelllang=en,[new lang].

Check this out:

  function! Color_NavajoNight()
   Change the current color scheme to Zenburn.
  enew
  execute 'Nread http://cream.cvs.sourceforge.net/' .
\ '*checkout*/cream/cream/cream-colors-zenburn.vim'
  execute saveas  . tempname()
  source %
  endfunction
   map silent F12  :call Color_NavajoNight()CR
  imap silent F12 C-o:call Color_NavajoNight()CR
  vmap silent F12 :C-ucall Color_NavajoNight()CR

Pressing F12 will automatically change your color scheme to the
Zenburn color scheme stored in the Cream CVS repository.

Really, the only two tricks are using Netrw to read the file, and then
saving it with a name so that you can source it.


-- 
Steve Hall  [ digitect dancingpaper com ]
:: Cream... something good to put in your Vim!
::   http://cream.sourceforge.net




Re: How do I stop a mapping from looking like a mapping?

2006-07-13 Thread Yakov Lerner

On 7/13/06, Yakov Lerner [EMAIL PROTECTED] wrote:

:imap ctrl-Zf foreach 


Correction. I wanted to write:

:imap c-Zf foreach 

Yakov


Re: How do I stop a mapping from looking like a mapping?

2006-07-13 Thread Hari Krishna Dara

On Thu, 13 Jul 2006 at 9:21am, Yakov Lerner wrote:

 On 7/13/06, Peter Hodge [EMAIL PROTECTED] wrote:
  However, if I type anything beginning with 'for', the letters disappear
  until I
  type something that is not part of the mapping.  I understand this is
  the
  standard behaviour, but is there any way to change it so I can see
   what I am
  typing?

 Although there is no stardard option for imap to do this (make incompete
 mapping visible; yes I'd find it seful, too), I found  a weird trick that
 does what you want.
 Does the following do what you want:
 -
 :imap h c-r=PrecedingChars(6) !=# 'foreac' ? 'h' : ExpandForeach() cr

 function! ExpandForeach()  expansion of the foreach mapping
  nb: 'foreac' is already there. So we don't need to repeat it
 return h() {\n}\Left
 endfunction

 function! PrecedingChars(n)
  return n chars preceding cursor in rhs of :imap mapping
 return getline('.')[col('.')-1-a:n : col('.')-2]
 endfunction
 ---

Very clever alternative to iab. You can take advantage of the new expr
maps to simplify and generalize this as below (note, I changed the
mapping to not remap):

:inoremap expr h CheckExpand('foreac', 'h', h() {\n}\Left)  expansion of
the foreach mapping

function! CheckExpand(precChars, curChar, expansion)
if PrecedingChars(strlen(a:precChars)) ==# a:precChars
 nb: precChar is already there. So we don't need to repeat it
return a:expansion
else
return a:curChar
endif
endfunction

function! PrecedingChars(n)
 return n chars preceding cursor in rhs of :imap mapping
return getline('.')[col('.')-1-a:n : col('.')-2]
endfunction

This method also allows you to do very detailed conditional checks to
decide if the expansion should be made or not (to check if you are
inside a comment using the current syntax group, e.g.).

-- 
HTH,
Hari


 Explanation: this remaps 'h' character to check 6 preceding chars.
 If 6 preceding chars are 'foreac', then it is expanded into your you
 foreach-template. Otherwise, literas 'h' is inserted. Since this is
 1-char-length mapping, there's no delay and no invisibilities.

 If you wonder where is expansion (rhs) of your template, it's
 inside function ExpandForeach(). The function PrecedingChars()
 is generic and doesn't change when you change rhs of your template.

 2.
 If you find this too complex, and you don't want to
 press space or tab after 'foreach' (supposedly because it
 makes 8 chars instead of 7?) , then can I suggest either this simple
weirdity:

  :iab foreac foreach ...

 (In which case, you get to type 'foreac' then space, which makes
 total 7 characters not 8.), or this mapping

 :imap ctrl-Zf foreach 

 which is economy of 5 chars on the lhs side. (You type ctrl-z then f)

 Yakov



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Re: How do I stop a mapping from looking like a mapping?

2006-07-13 Thread Yakov Lerner

On 7/13/06, Hari Krishna Dara [EMAIL PROTECTED] wrote:


On Thu, 13 Jul 2006 at 9:21am, Yakov Lerner wrote:

 On 7/13/06, Peter Hodge [EMAIL PROTECTED] wrote:
  However, if I type anything beginning with 'for', the letters disappear
  until I
  type something that is not part of the mapping.  I understand this is
  the
  standard behaviour, but is there any way to change it so I can see
   what I am
  typing?

 Although there is no stardard option for imap to do this (make incompete
 mapping visible; yes I'd find it seful, too), I found  a weird trick that
 does what you want.
 Does the following do what you want:
 -
 :imap h c-r=PrecedingChars(6) !=# 'foreac' ? 'h' : ExpandForeach() cr

 function! ExpandForeach()  expansion of the foreach mapping
  nb: 'foreac' is already there. So we don't need to repeat it
 return h() {\n}\Left
 endfunction

 function! PrecedingChars(n)
  return n chars preceding cursor in rhs of :imap mapping
 return getline('.')[col('.')-1-a:n : col('.')-2]
 endfunction
 ---

Very clever alternative to iab. You can take advantage of the new expr
maps to simplify and generalize this as below (note, I changed the
mapping to not remap):

:inoremap expr h CheckExpand('foreac', 'h', h() {\n}\Left)  expansion of
the foreach mapping

function! CheckExpand(precChars, curChar, expansion)
if PrecedingChars(strlen(a:precChars)) ==# a:precChars
 nb: precChar is already there. So we don't need to repeat it
return a:expansion
else
return a:curChar
endif
endfunction

function! PrecedingChars(n)
 return n chars preceding cursor in rhs of :imap mapping
return getline('.')[col('.')-1-a:n : col('.')-2]
endfunction


Nice generalization, yes.

Yakov


Re: script installation from remote url

2006-07-13 Thread Mikolaj Machowski
Dnia czwartek, 13 lipca 2006 11:26, Yakov Lerner napisał:
 If not, then what's the closest existing thing to such :InstallScript
 functionality ?

You have also GetLatestVimScripts. But this is targeted directly to
vim-online.

m.



seaching for selected multiline expression

2006-07-13 Thread J.Hofmann
Hello,

I have a mapping which immediately searches for visually selected items.
It achieves this by yanking the selected text and exec[utes] a search for
the register content 
This works so far.

  vmap / y:execute /.escape(@,'[]/\.*')CR

Now I tried this first time for multiline selects, but it does not work:
Selecting this:

USE ICCS_2005
GO

leads to:
- E486: Pattern not found: USE [EMAIL PROTECTED]@  

To surround the error, I shortened the abbreviation to
   vmap / y:execute /.@CR,
this causes the same error message.

What is ^@ ?
How can I have \n instead of thes ^@ - characters to make the search work?

Thank You

Joachim
###

This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange.
For more information, connect to http://www.f-secure.com/


taming omni completion

2006-07-13 Thread Maciej Kalisiak

I'm using Vim 7.0 on WinXP SP2.  I don't think I did anything specific
to turn on omni-completion (perhaps it's on by default? I'm editing
Python files), and I'm in no rush to start using it, although if it
was non-intrusive I wouldn't mind leaving it on.  The problem is that
I've recently modified my path variable in Vim, and now whenever
omni-completion kicks in -- and it's often -- Vim comes to a lng
stop, 'scanning tags'.  I take it that the scan goes through all files
in my path.  Admittedly my path is now fairly deep:
   let home='C:\Documents\ and\ Settings\Maciek\My\ Documents\Home'
   let path.=','.home.'\python\**'
   let path.=','.home.'\research\**'
   let path.=',c:\Python24\Libs\**'
Probably the last entry is the killer.  Still, I chose to include
these directories/trees in my path as I find the :find command very
useful, much more than the omni-completion; hence if push comes to
shove, I'll ditch omni-complete first.

My question: can anything be done to improve the situation on the
omni-completion front?  Obviously the constant scanning is killing me;
making it faster without sacrificing path variable would be nice.
Also, I'd like to be able to trigger it only when I ask for it, and
not have it automatic.  Also, since I use ctrl-n and ctrl-p a lot to
complete the word under cursor *using only the current file*, I'd
prefer omni-completion to be under a different key combo.

Also, I would've thought omni-completion would use some sort of
caching mechanism, rather than rescanning all the files every single
time.  Doesn't it do that?  Most of the time I hit Ctrl-C to interrupt
the scanning of tags, so I can get on with my work, but I could have
sworn I let it run once or twice to completion before, with no
discernible improvement on subsequent completions...


Re: seaching for selected multiline expression

2006-07-13 Thread Benji Fisher
On Thu, Jul 13, 2006 at 06:02:40PM +0200, [EMAIL PROTECTED] wrote:
 Hello,
 
 I have a mapping which immediately searches for visually selected items.
 It achieves this by yanking the selected text and exec[utes] a search for
 the register content 
 This works so far.
 
   vmap / y:execute /.escape(@,'[]/\.*')CR
 
 Now I tried this first time for multiline selects, but it does not work:
 Selecting this:
 
 USE ICCS_2005
 GO
 
 leads to:
 - E486: Pattern not found: USE [EMAIL PROTECTED]@  
 
 To surround the error, I shortened the abbreviation to
vmap / y:execute /.@CR,
 this causes the same error message.
 
 What is ^@ ?
 How can I have \n instead of thes ^@ - characters to make the search work?
 
 Thank You
 
 Joachim

:execute / . substitute(@, \C-J, '\\n', 'g')

or

:execute / . substitute(@, \n, '\\n', 'g')

:help NL-used-for-Nul

HTH --Benji Fisher


Re: taming omni completion

2006-07-13 Thread Hari Krishna Dara

On Thu, 13 Jul 2006 at 12:04pm, Maciej Kalisiak wrote:

 I'm using Vim 7.0 on WinXP SP2.  I don't think I did anything specific
 to turn on omni-completion (perhaps it's on by default? I'm editing
 Python files), and I'm in no rush to start using it, although if it
 was non-intrusive I wouldn't mind leaving it on.  The problem is that
 I've recently modified my path variable in Vim, and now whenever
 omni-completion kicks in -- and it's often -- Vim comes to a lng
 stop, 'scanning tags'.  I take it that the scan goes through all files
 in my path.  Admittedly my path is now fairly deep:
 let home='C:\Documents\ and\ Settings\Maciek\My\ Documents\Home'
 let path.=','.home.'\python\**'
 let path.=','.home.'\research\**'
 let path.=',c:\Python24\Libs\**'
 Probably the last entry is the killer.  Still, I chose to include
 these directories/trees in my path as I find the :find command very
 useful, much more than the omni-completion; hence if push comes to
 shove, I'll ditch omni-complete first.

 My question: can anything be done to improve the situation on the
 omni-completion front?  Obviously the constant scanning is killing me;
 making it faster without sacrificing path variable would be nice.
 Also, I'd like to be able to trigger it only when I ask for it, and
 not have it automatic.  Also, since I use ctrl-n and ctrl-p a lot to
 complete the word under cursor *using only the current file*, I'd
 prefer omni-completion to be under a different key combo.

 Also, I would've thought omni-completion would use some sort of
 caching mechanism, rather than rescanning all the files every single
 time.  Doesn't it do that?  Most of the time I hit Ctrl-C to interrupt
 the scanning of tags, so I can get on with my work, but I could have
 sworn I let it run once or twice to completion before, with no
 discernible improvement on subsequent completions...


You are probably talking about the insert-mode completion rather than
the omni-completion. Omni completion is meant is similar to the MS
intellisense, and is not turned on by default. You also need specific
plugins to use that. In contrast, the insert-mode completion is on by
default, and gets triggered when you use ^N, ^P etc. in insert mode.
Also, this completion doesn't use your 'path' but by default your tags
setting, and all the loaded buffers etc. This can be customized by using
the 'complete' option (e.g., you can completely avoid looking into the
tags files). It is possible that you recently added more tags files
which is causing this delay in completion. Actually, without any change
in tags files, I also saw a difference in performance of the insert-mode
completion in Vim7 compared to Vim6.3, and not sure if disabling the
menu will make any difference. You might want to check removing menu
and menuone from 'completeopt' will make any difference (this should
disable popup menu).

Since you mentioned that you find the :find command very useful, might I
put in a plug for my lookupfile.vim plugin? When you use LUPath command,
it cleverly takes advantage of the Vim7 completion menu (which works
even when you disable it in 'completeopt') to lookup matching files as
you type in a partial filename. You can download it from:

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

-- 
HTH,
Hari

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Re: taming omni completion

2006-07-13 Thread Maciej Kalisiak

On 13/07/06, Hari Krishna Dara [EMAIL PROTECTED] wrote:

You are probably talking about the insert-mode completion rather than
the omni-completion. Omni completion is meant is similar to the MS
intellisense, and is not turned on by default.


Ahhh, I see, yes, I think you're right.

But is there some option which causes it to trigger *automatically*?
Sometimes as I'm midway through typing in a function name or
identifier the popup comes up automatically, without me having pressed
^N...  that's one of the most annoying parts.


In contrast, the insert-mode completion is on by
default, and gets triggered when you use ^N, ^P etc. in insert mode.
Also, this completion doesn't use your 'path' but by default your tags
setting, and all the loaded buffers etc.


Hmm, I noticed the huge performance hit when I extended my path
variable, without having touched my tags, but perhaps Vim in the
background regenerates my tags *based on* my path variable, meaning
it's producing a much larger tags file now...


This can be customized by using
the 'complete' option (e.g., you can completely avoid looking into the
tags files). It is possible that you recently added more tags files
which is causing this delay in completion. Actually, without any change
in tags files, I also saw a difference in performance of the insert-mode
completion in Vim7 compared to Vim6.3, and not sure if disabling the
menu will make any difference. You might want to check removing menu
and menuone from 'completeopt' will make any difference (this should
disable popup menu).


Well, doing 'set completeopt=' (i.e., set it to nothing; previously it
was set to 'preview,menu') seems to speed things up significantly,
although it is still not lightning fast as before.  But we're talking
here a difference of going from 10s to 1s wait times!  The 1s wait is
almost acceptable now.


Since you mentioned that you find the :find command very useful, might I
put in a plug for my lookupfile.vim plugin? When you use LUPath command,
it cleverly takes advantage of the Vim7 completion menu (which works
even when you disable it in 'completeopt') to lookup matching files as
you type in a partial filename. You can download it from:

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


Thanks!  I'll check it out, it sounds very interesting.


Re: auto upper/lower in replace pattern based on search pattern?

2006-07-13 Thread Marshall Abrams

Thanks--keepcase.vim is great.  So now with
:%s/firstname/\=KeepCase(submatch(0), 'LastName')/ig
I can replace all instances of
firstname with lastname
firstName with lastName
FirstName with LastName

But \=KeepCase(submatch(0), '') is a mouthful.
Not a problem; that exact expression does what I'll want 99% of the 
time, so I've already mapped it to a control-key.  And there are other 
ways to abbreviate.


Still, this seems *such* a useful function in a programmer's editor, it 
seems worthwhile to build it into the :substitute command as some kind 
of optional behavior.


How about one of these:

:s/firstname/LastName/k ['k' for keepcase]

:set MaGiC

or some kind of delimiter that can be stuck into a pattern to say use 
KeepCase() on this part.  OK, I know there aren't many delimiters that 
are available at this point.


Does this make any sense as a possible future feature?


Marshall



On Jul 7, 2006, at 4:26 AM, Yakov Lerner wrote:


On 7/7/06, Marshall Abrams [EMAIL PROTECTED] wrote:

Hate to ask this because I'm sure the answer is already out there
somewhere, but I've searched help and vim.org until I was blue in the
fingers  I could swear that I remember from a few years back that
there's a way to do this.  Can't remember whether it required 
something

special in the patterns or some special :set variable or loading a
plugin.

I want to the replace pattern in a substitution to be able to figure
out whether I want an upper or lower character in the replacement,
depending on whether the search pattern matched an upper or lower
character.  Very useful for substitutions on studlyCaps.

For example, suppose I want to replace all instances of 'first' with
'last' and of 'First' with 'Last'.  Can I do that with a slinge :s///
line?


Try this script:
   http://www.vim.org/scripts/script.php?script_id=6
   keepcase.vim : Functions for doing case-persistant substitutions

Yakov



Marshall Abrams   Programmer
[EMAIL PROTECTED]  5points.net, LLC
Voice: 518-392-5505  www.5points.net  Fax: 518-392-8410

CONFIDENTIALITY NOTICE:
This communication and any accompanying document(s) are confidential
and privileged. They are intended for the sole use of the addressee.
If you receive this transmission in error,  you are advised that any
disclosure,  copying,  distribution,  or the taking of any action in
reliance upon the communication is strictly prohibited.  If you have
received this communication in error,  please contact us by email at
[EMAIL PROTECTED],  or by telephone at  (518) 392-5505.
Thank you.



Mapping using Let in Autocmd

2006-07-13 Thread JD Miller

 Comment out a line by inserting #  then move to the lower line
map F10 i# Eschj

 Here I try to do the same thing but use the BufEnter event to make the
comment character
 change depending on the file type (*.asp). 

let comment_char=#
autocmd BufEnter *.asp let comment_char=' 
execute map F10 i . comment_char .  Eschj

 But the comment_char variable never seems to see the let assignment in the
 autocmd statement.  What have I missed here?  Is there a better approach?
 Thank you.

-- 
View this message in context: 
http://www.nabble.com/Mapping-using-Let-in-Autocmd-tf1938850.html#a5313061
Sent from the Vim - General forum at Nabble.com.



Function To Search Directory And Display File List

2006-07-13 Thread Tom Purl
Hi, I'm a Vim scripting newbie, and had a pretty general question.

I'm would like to write a function that does the following:

1. Searches a directory for all files that end in the string Template
2. Return those file names to the user as chooseable list, similar to
the way that the spell checker functionality works when you use the z=
command.

Would anyone know how to do this?  I checked the functions help in Vim,
but couldn't find what I was looking for.

Thanks in advance for any guidance!

Tom Purl



Re: taming omni completion

2006-07-13 Thread Hari Krishna Dara

On Thu, 13 Jul 2006 at 1:15pm, Maciej Kalisiak wrote:

 On 13/07/06, Hari Krishna Dara [EMAIL PROTECTED] wrote:
  You are probably talking about the insert-mode completion rather than
  the omni-completion. Omni completion is meant is similar to the MS
  intellisense, and is not turned on by default.

 Ahhh, I see, yes, I think you're right.

 But is there some option which causes it to trigger *automatically*?
 Sometimes as I'm midway through typing in a function name or
 identifier the popup comes up automatically, without me having pressed
 ^N...  that's one of the most annoying parts.

I am not aware of anything that can do this. Which language are you
using? Take a look at the ftplugins for the language and see if it is
doing anything specific to completion.


  In contrast, the insert-mode completion is on by
  default, and gets triggered when you use ^N, ^P etc. in insert mode.
  Also, this completion doesn't use your 'path' but by default your tags
  setting, and all the loaded buffers etc.

 Hmm, I noticed the huge performance hit when I extended my path
 variable, without having touched my tags, but perhaps Vim in the
 background regenerates my tags *based on* my path variable, meaning
 it's producing a much larger tags file now...

As far as I know, Vim doesn't generate tags file, except for the help
documentation. However, I noticed the i and d options in 'complete'
setting which say that Vim scans for all the included files. I don't
know if the files are looked up in the 'path' setting, but you might
having this issue (check if you have these values in 'complete'.


  This can be customized by using
  the 'complete' option (e.g., you can completely avoid looking into the
  tags files). It is possible that you recently added more tags files
  which is causing this delay in completion. Actually, without any change
  in tags files, I also saw a difference in performance of the insert-mode
  completion in Vim7 compared to Vim6.3, and not sure if disabling the
  menu will make any difference. You might want to check removing menu
  and menuone from 'completeopt' will make any difference (this should
  disable popup menu).

 Well, doing 'set completeopt=' (i.e., set it to nothing; previously it
 was set to 'preview,menu') seems to speed things up significantly,
 although it is still not lightning fast as before.  But we're talking
 here a difference of going from 10s to 1s wait times!  The 1s wait is
 almost acceptable now.

Good to know this.


  Since you mentioned that you find the :find command very useful, might I
  put in a plug for my lookupfile.vim plugin? When you use LUPath command,
  it cleverly takes advantage of the Vim7 completion menu (which works
  even when you disable it in 'completeopt') to lookup matching files as
  you type in a partial filename. You can download it from:
 
  http://www.vim.org//script.php?script_id=1581

 Thanks!  I'll check it out, it sounds very interesting.

And please send me your feedback, and don't forget to rate it, if you
like it.

-- 
Thanks,
Hari

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Re: Mapping using Let in Autocmd

2006-07-13 Thread Hari Krishna Dara

On Thu, 13 Jul 2006 at 10:37am, JD Miller wrote:


  Comment out a line by inserting #  then move to the lower line
 map F10 i# Eschj

  Here I try to do the same thing but use the BufEnter event to make the
 comment character
  change depending on the file type (*.asp).

 let comment_char=#
 autocmd BufEnter *.asp let comment_char='
 execute map F10 i . comment_char .  Eschj

  But the comment_char variable never seems to see the let assignment in the
  autocmd statement.  What have I missed here?  Is there a better approach?
  Thank you.



The reason is, at the time the map is created, you are fixing the
comment_char based on the value at that time. In other means, you are
not using the dynamic value of comment_char variable. Try this
instead (assuming you have Vim7):

nnoremap F10 iC-R=comment_charCREschj

-- 
HTH,
Hari

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Re: Function To Search Directory And Display File List

2006-07-13 Thread Hari Krishna Dara

On Thu, 13 Jul 2006 at 12:58pm, Tom Purl wrote:

 Hi, I'm a Vim scripting newbie, and had a pretty general question.

 I'm would like to write a function that does the following:

 1. Searches a directory for all files that end in the string Template
 2. Return those file names to the user as chooseable list, similar to
 the way that the spell checker functionality works when you use the z=
 command.

 Would anyone know how to do this?  I checked the functions help in Vim,
 but couldn't find what I was looking for.

 Thanks in advance for any guidance!

 Tom Purl


From your description, it is not clear if this will be part of a larger
script that you are developing. If all that you want to do is ability to
search and open the file, one of the existing plugins might be able to
help you. But if you want to ask the user to select one and do something
with that selection, you can use the glob() and inputlist() functions to
do this, something like this:

let files = glob(dir.'*Template')
if files != ''
  let filelist = split(files, \n)
  let sel = inputlist(['Select file:']+filelist)
  if sel != -1
let selectedFile = filelist[sel]
  endif
endif

-- 
HTH,
Hari

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Re: Function To Search Directory And Display File List

2006-07-13 Thread Tim Chase

1. Searches a directory for all files that end in the string Template
2. Return those file names to the user as chooseable list, similar to
the way that the spell checker functionality works when you use the z=
command.



Well, as an ugly first-pass hack:

:let s = expand(*template)
:echo substitute(\n.s.\n, 
'^\%([^[:cntrl:]]*[[:cntrl:]]\)\{'.(confirm('Which file?', 
s)).'}\([^[:cntrl:]]*\).*', '\1', 'g')


Those two lines create a prompt with available matches for 
whatever is stashed in s.


Instead of an :echo you can do an assignment, or make it the 
return value of a function so you don't have to recreate this 
beast repeatedly.


It can be wrapped in a function if desired.  Hari's suggestion 
was a good one, but requires Vim7 (at least it didn't work on 6.3 
when I tried it because of the need for the inputlist() and 
split() functions).  As you reference the like spell-checker, 
you're likely running 7.0 and thus are safe with his much clearer 
method.


The above two-liner, despite its brutish opacity, should work at 
least back to 6.0.


-tim





How to Override Backup Control to Implement File Versioning?

2006-07-13 Thread Robert Ingraham
Hi,
 
I've read through the manual and checked out the FAQ, but I can't see how to
implement file versioning in Vim.
 
What I'd like to do is mimic the VMS file versioning feature wherein if you
edit a file (say, file.txt) , the original is saved as file.txt.1. 
Subsequent backups of the same file are saved as file.txt.2, file.txt.3 and
so forth.  In this case, the most recent backup would be file.txt.3 and second
oldest backup would be file.txt.2 and the original file would be
file.txt.1.
Of course, if there are no changes to the file, then no incremental backup file
is created.
 
I looked into writing a script to do this but, being new to Vim scripting, I
didn't see a way to hook into the internal backup logic, or if that's even the
right way to accomplish this.  I'd like it to be automatic, so the user doesn't
have to do anything different when saving a file (like having to run a script
before saving.)
 
Any pointers would be greatly appreciated.
 
Thanks,
Bob

--

 
NOTICE: This email message is for the sole use of the
 intended recipient(s) and may contain confidential and
 privileged information. Any unauthorized review, use,
 disclosure or distribution is prohibited. If you are not the
 intended recipient, please contact the sender by reply email
 and destroy all copies of the original message.

--



How to Override Backup Control to Implement File Versioning?

2006-07-13 Thread Robert Ingraham
Hi,
 
I've read through the manual and checked out the FAQ, but I can't see how to
implement file versioning in Vim.
 
What I'd like to do is mimic the VMS file versioning feature wherein if you
edit a file (say, file.txt) , the original is saved as file.txt.1. 
Subsequent backups of the same file are saved as file.txt.2, file.txt.3 and
so forth.  In this case, the most recent backup would be file.txt.3 and second
oldest backup would be file.txt.2 and the original file would be
file.txt.1.
Of course, if there are no changes to the file, then no incremental backup file
is created.
 
I looked into writing a script to do this but, being new to Vim scripting, I
didn't see a way to hook into the internal backup logic, or if that's even the
right way to accomplish this.  I'd like it to be automatic, so the user doesn't
have to do anything different when saving a file (like having to run a script
before saving.)
 
Any pointers would be greatly appreciated.
 
Thanks,
Bob

--

 
NOTICE: This email message is for the sole use of the
 intended recipient(s) and may contain confidential and
 privileged information. Any unauthorized review, use,
 disclosure or distribution is prohibited. If you are not the
 intended recipient, please contact the sender by reply email
 and destroy all copies of the original message.

--



Re: Function To Search Directory And Display File List

2006-07-13 Thread Tom Purl
 From your description, it is not clear if this will be part of a larger
 script that you are developing. If all that you want to do is ability to
 search and open the file, one of the existing plugins might be able to
 help you.

I'm adding a function to the potwiki script so that I can create a new
wiki page based on a template.

 But if you want to ask the user to select one and do something
 with that selection, you can use the glob() and inputlist() functions to
 do this, something like this:

 let files = glob(dir.'*Template')
 if files != ''
   let filelist = split(files, \n)
   let sel = inputlist(['Select file:']+filelist)
   if sel != -1
 let selectedFile = filelist[sel]
   endif
 endif

This example worked very well for me.  Thanks a ton!

Tom Purl



Re: Function To Search Directory And Display File List

2006-07-13 Thread Tom Purl
 1. Searches a directory for all files that end in the string Template
 2. Return those file names to the user as chooseable list, similar to
 the way that the spell checker functionality works when you use the z=
 command.

 Well, as an ugly first-pass hack:

 :let s = expand(*template)
 :echo substitute(\n.s.\n,
 '^\%([^[:cntrl:]]*[[:cntrl:]]\)\{'.(confirm('Which file?',
 s)).'}\([^[:cntrl:]]*\).*', '\1', 'g')

 Those two lines create a prompt with available matches for
 whatever is stashed in s.

 Instead of an :echo you can do an assignment, or make it the
 return value of a function so you don't have to recreate this
 beast repeatedly.

Thanks a *ton* Tim!  This looks very succinct (if not a bit
frightening).  I'll definitely try this one out too.

 It can be wrapped in a function if desired.  Hari's suggestion
 was a good one, but requires Vim7 (at least it didn't work on 6.3
 when I tried it because of the need for the inputlist() and
 split() functions).  As you reference the like spell-checker,
 you're likely running 7.0 and thus are safe with his much clearer
 method.

Wow, I'm glad that I started Vim scripting after version 7 was released,
because it looks like it was much more difficult to script using version
6.

 The above two-liner, despite its brutish opacity, should work at
 least back to 6.0.

Thanks again!

Tom Purl



Re: taming omni completion

2006-07-13 Thread Bram Moolenaar

Maciej Kalisiak wrote:

 I'm using Vim 7.0 on WinXP SP2.  I don't think I did anything specific
 to turn on omni-completion (perhaps it's on by default? I'm editing
 Python files), and I'm in no rush to start using it, although if it
 was non-intrusive I wouldn't mind leaving it on.  The problem is that
 I've recently modified my path variable in Vim, and now whenever
 omni-completion kicks in -- and it's often -- Vim comes to a lng
 stop, 'scanning tags'.  I take it that the scan goes through all files
 in my path.  Admittedly my path is now fairly deep:
 let home='C:\Documents\ and\ Settings\Maciek\My\ Documents\Home'
 let path.=','.home.'\python\**'
 let path.=','.home.'\research\**'
 let path.=',c:\Python24\Libs\**'
 Probably the last entry is the killer.  Still, I chose to include
 these directories/trees in my path as I find the :find command very
 useful, much more than the omni-completion; hence if push comes to
 shove, I'll ditch omni-complete first.

You don't mention what you are actually doing.  Omni completion should
only do something when using CTRL-X CTRL-O in Insert mode.  Otherwise it
should not do anything.  However, it's possible that mappings change
behavior.  Then where does this mapping come from?  Use this to find
out:
:verbose imap

 My question: can anything be done to improve the situation on the
 omni-completion front?  Obviously the constant scanning is killing me;
 making it faster without sacrificing path variable would be nice.
 Also, I'd like to be able to trigger it only when I ask for it, and
 not have it automatic.  Also, since I use ctrl-n and ctrl-p a lot to
 complete the word under cursor *using only the current file*, I'd
 prefer omni-completion to be under a different key combo.

Hmm, perhaps you are not talking about omni completion but about normal
Insert mode completion.  This now scans other files sooner than in
previous versions, so that the menu can be filled.  Note that you don't
have to wait for this to complete, typing a character will stop it.

 Also, I would've thought omni-completion would use some sort of
 caching mechanism, rather than rescanning all the files every single
 time.  Doesn't it do that?  Most of the time I hit Ctrl-C to interrupt
 the scanning of tags, so I can get on with my work, but I could have
 sworn I let it run once or twice to completion before, with no
 discernible improvement on subsequent completions...

Caching would add to the complexity, and Insert mode completion already
is too complex.  It needs to be cleaned up first.

-- 
You have heard the saying that if you put a thousand monkeys in a room with a
thousand typewriters and waited long enough, eventually you would have a room
full of dead monkeys.
(Scott Adams - The Dilbert principle)

 /// 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: How to Override Backup Control to Implement File Versioning?

2006-07-13 Thread Yakov Lerner

On 7/13/06, Robert Ingraham [EMAIL PROTECTED] wrote:

Hi,

I've read through the manual and checked out the FAQ, but I can't see how to
implement file versioning in Vim.

What I'd like to do is mimic the VMS file versioning feature wherein if you
edit a file (say, file.txt) , the original is saved as file.txt.1.
Subsequent backups of the same file are saved as file.txt.2, file.txt.3 and
so forth.  In this case, the most recent backup would be file.txt.3 and second
oldest backup would be file.txt.2 and the original file would be
file.txt.1.
Of course, if there are no changes to the file, then no incremental backup file
is created.

I looked into writing a script to do this but, being new to Vim scripting, I
didn't see a way to hook into the internal backup logic, or if that's even the
right way to accomplish this.  I'd like it to be automatic, so the user doesn't
have to do anything different when saving a file (like having to run a script
before saving.)

Any pointers would be greatly appreciated.


Please take a look at savevers plugin:
http://www.vim.org/scripts/script.php?script_id=89

Very good plugin, I'm using it all the time on all computers where I use vim.
Many people use it, too.

It needs some config setting to begin working.
My settings are, for example

let savevers_types='*'
let savevers_max=
let savevers_purge=1
let savevers_dirs=~/tmp/
patchmode is required for savevers to work

Yakov


Re: How to Override Backup Control to Implement File Versioning?

2006-07-13 Thread Bob Hiestand

On 7/13/06, Robert Ingraham [EMAIL PROTECTED] wrote:

What I'd like to do is mimic the VMS file versioning feature wherein if you
edit a file (say, file.txt) , the original is saved as file.txt.1.
Subsequent backups of the same file are saved as file.txt.2, file.txt.3 and
so forth.  In this case, the most recent backup would be file.txt.3 and second
oldest backup would be file.txt.2 and the original file would be
file.txt.1.
Of course, if there are no changes to the file, then no incremental backup file
is created.

I looked into writing a script to do this but, being new to Vim scripting, I
didn't see a way to hook into the internal backup logic, or if that's even the
right way to accomplish this.  I'd like it to be automatic, so the user doesn't
have to do anything different when saving a file (like having to run a script
before saving.)

Any pointers would be greatly appreciated.


A quick search on vim.sf.net reveals:

http://vim.sourceforge.net/scripts/script.php?script_id=89

which sounds very much like what you describe.


Re: seaching for selected multiline expression

2006-07-13 Thread Gary Johnson
On 2006-07-13, [EMAIL PROTECTED] wrote:
 Hello,
 
 I have a mapping which immediately searches for visually selected items.
 It achieves this by yanking the selected text and exec[utes] a search for
 the register content 
 This works so far.
 
   vmap / y:execute /.escape(@,'[]/\.*')CR
 
 Now I tried this first time for multiline selects, but it does not work:
 Selecting this:
 
 USE ICCS_2005
 GO
 
 leads to:
 - E486: Pattern not found: USE [EMAIL PROTECTED]@  

 How can I have \n instead of thes ^@ - characters to make the search work?

Someone posted a similar mapping to this list some time ago and I 
just recently enhanced it to work with multi-line patterns.

vmap silent g/ y/C-R=substitute(escape(@, '\\/.*$^~[]'), '\n', '\\n', 
'g')CRCR

HTH,
Gary

-- 
Gary Johnson | Agilent Technologies
[EMAIL PROTECTED] | Wireless Division
 | Spokane, Washington, USA


Re: Awareness of python import semantics for [i, etc.?

2006-07-13 Thread Gary Johnson
On 2006-07-13, Benji Fisher [EMAIL PROTECTED] wrote:
 On Wed, Jul 12, 2006 at 03:48:22PM -0700, John Reese wrote:
  So there's this handy [i command that, when filetype=c, displays the
  first line mentioning the identifier under the cursor, which will
  often be its definition.  The especially handy thing about it is that
  it knows about #include lines and will search through them as well
  when looking for the first match.  You can also put the cursor over
  the .h file between the quotes and hit gf, and if the path and
  suffixesadd options are set appropriately, it will jump you to the .h
  file.
  
  The point is, vim can be configured to know how to find C include
  files and use them in various ways.
  
  I was wondering if there was a way to get it to have a similar level
  of knowledge about Python modules.  In C,
  
   #include z.h
  will look for z.h in the current directory.  That's easy enough... the
  Python equivalent is something like
   import z
  
  But that actually just loads z.py from the current directory (or from
  a bunch of other possible places, including system library directories
  and directories listed in the PYTHONPATH environment variable) and
  puts the name z into your namespace, and if you want to refer to
  something defined in z.py, you qualify it:  z.someFunction().  A
  Python-aware [i would know that if I have the cursor on the
  someFunction in z.someFunction, then it needs to look for the word
  someFunction in z.py.
  
  There's also this from path import syntax:
   from a.b.c import z
  
  which might mean that relative to the current directory there's a file
  a/b/c/z.py that would need to be looked through if you used [i.
  
  So, anyway, this all seems very complicated, but I figured it wasn't
  entirely out of the question that something was supported or
  available, especially given the existence of the compiled-in Python
  scripting option.  Does anyone know of anything to let vim understand
  Python import syntax and use it for [i and similar commands?
 
  I am not sure if everything you want to do is possible or easy, but
 I suggest you start here:
 
 :help include-search
 :help 'path'
 :help 'include'
 :help 'includeexpr'
 
 See, for example, the ftplugin files for plaintex and tex.

A lot of this is already incorporated into the 
$VIMRUNTIME/ftplugin/python.vim plugin.  For example, gf works fine 
with Python import statements.  I don't know about [i because I 
never use it.  There are a number of Python plugins at vim.sf.net.  
One of those may have what you want if the standard python.vim 
plugin doesn't already make [i just work.

HTH,
Gary

-- 
Gary Johnson | Agilent Technologies
[EMAIL PROTECTED] | Wireless Division
 | Spokane, Washington, USA


Re: taming omni completion

2006-07-13 Thread Hari Krishna Dara

On Thu, 13 Jul 2006 at 10:36pm, Bram Moolenaar wrote:

[snip]

 Hmm, perhaps you are not talking about omni completion but about normal
 Insert mode completion.  This now scans other files sooner than in
 previous versions, so that the menu can be filled.  Note that you don't
 have to wait for this to complete, typing a character will stop it.

My observation is that the time it takes to come up with the first match
is much longer now than before. Previously, the first match used to come
almost immediately, if there is a match in the loaded buffers, and the
scan in external files (tags etc.) used to continue in the background.
Now, I think this is somewhat broken in the sense, I have to wait for
too long for the completion to show up, even though I know there is a
word matching in one of the loaded buffers.

[snip]

-- 
Thanks,
Hari

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Re: Mapping using Let in Autocmd

2006-07-13 Thread JD Miller

Thanks much Hari, 

I added a space before the Esc and your method works nicely.

map F1 iC-R=comment_charCR Eschj

Jim
-- 
View this message in context: 
http://www.nabble.com/Mapping-using-Let-in-Autocmd-tf1938850.html#a5318140
Sent from the Vim - General forum at Nabble.com.



Motions in visual(line|block)

2006-07-13 Thread Max Dyckhoff
I've noticed that using some motions - specifically i{ and suchlike -
will cancel a visual line/block and turn it into regular visual mode
instead, which is rather annoying. Is this intentional, or a bug?

I should just mention that my new favourite command is =a{, which
makes me smile every time I use it, and which really annoys my Visual
Studio using colleagues.

Chairs!
--
Max Dyckhoff 
AI Engineer
Bungie Studios



Re: taming omni completion

2006-07-13 Thread Maciej Kalisiak

On 13/07/06, Bram Moolenaar [EMAIL PROTECTED] wrote:

Hmm, perhaps you are not talking about omni completion but about normal
Insert mode completion.


Thanks to Hari's post earlier, I now believe so, yes.


 This now scans other files sooner than in
previous versions, so that the menu can be filled.  Note that you don't
have to wait for this to complete, typing a character will stop it.


Ah, interesting.  The issue for me is that it doesn't really stop
immediately; it stops at the end of the current scanning stage
(i.e., it will stop once it *finishes* scanning the current object
being scanned, be it tags or an actual file).  This wasn't noticeable
earlier, or at least it never drew my attention, but now each object
scan takes somewhere between 2 to 5 seconds, which is odd.  This is
on a fairly fast machine.  The included Python files, as well as the
tags file, are fairly simple and short (most 200 lines, a handful
~1000 lines; the tags file in current directory has about 1000 lines).
2 to 5 seconds seems absurdly too much time for said files, no?

Hence, although an improvement, hitting a key immediately after a ^P,
still takes about 5 seconds to stop... way too much if you're used to
pressing ^P every 3rd or 4th identifier...

BTW, my previous estimate of the full scan was incorrect; I've never
had the stomach to wait through the whole thing... I just timed it
more explicitly, but aborted past the 30 seconds mark... it wasn't
nearly done 10% of included files...


Sudden problem with: exe set listchars=tab:\xbb\xb7,trail:\xb7

2006-07-13 Thread Yakov Lerner

I always had this line in my vimrc:
  exe set listchars=tab:\xbb\xb7,trail:\xb7
(It is equivalent to set listchars=tab:»·,trail:·)
Suddenly his line stopped working. (I didn't change it)
It assigns now empty value to listchars:
   set listchars?
   listchars=tab:,trail:

Command L=line  :set listchars=tab:»·,trail:·
stopped to work, too.
It prints E474: Invalid argument: listchars=tab:»·,trail:·

What can be causing this ?

Yakov


Re: How do I stop a mapping from looking like a mapping?

2006-07-13 Thread Peter Hodge
Hi Hari, Yakov,

Thank you very much for your help! Yakov, thank you for an effective solution,
Hari thank you for providing such a flexible way to use it!

kind regards,
Peter



 
On Yahoo!7 
Dating: It's free to join and check out our great singles! 
http://www.yahoo7.com.au/personals


Re: Autoselect language for spell

2006-07-13 Thread Luis A. Florit
* El 12/07/06 a las 23:34, Stefan Karlsson chamullaba:

  Is there an easy way to autoselect language for the builtin
  spell checker in vim 7.0? Vimspell plugin has this functionality:
  the plugin looks for a specified number of lines and try to guess
  which language should it use.
  
 
 Set spelllang -- yes there is three l in that option :-) -- to a 
 comma-separated list of the languages you're interested in. Vim will figure 
 out which of them to use.
 
 For example, this is how I do it in my .vimrc (I want US English and Swedish):
 
   set spelllang=en_us,sv

Oh... perfect
How I didn't find this in the manual?
I (think I) searched thoroughly...
Anyway, thanks a lot

L.



Can't put text with P, but p still works

2006-07-13 Thread Dr Bean
map P reveals no mappings. 

This is the vim on Fedora Core 3.

:version
VIM - Vi IMproved 6.3 (2004 June 7, compiled Oct 19 2004 17:17:57)
適用済パッチ: 1-21, 23-24, 26, 28-30
Modified by [EMAIL PROTECTED]
Compiled by [EMAIL PROTECTED]
Huge 版 without GUI.  機能の一覧 有効(+)/無効(-)
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+cryptv +cscope +dialog_con +diff +digraphs -dnd -ebcdic +emacs_tags +eval
+ex_extra +extra_search +farsi +file_in_path +find_in_path +folding -footer
+fork() +gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap
 +libcall +linebreak +lispindent +listcmds +localmap +menu +mksession
+modify_fname +mouse -mouseshape +mouse_dec +mouse_gpm -mouse_jsbterm
+mouse_netterm +mouse_xterm +multi_byte +multi_lang -netbeans_intg -osfiletype
+path_extra +perl +postscript +printer +python +quickfix +rightleft -ruby
+scrollbind +signs +smartindent -sniff +statusline -sun_workshop +syntax
+tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse
+textobjects +title -toolbar +user_commands +vertsplit +virtualedit +visual
+visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup
-X11 -xfontset -xim -xsmp -xterm_clipboard -xterm_save
  システム vimrc: /etc/vimrc
ユーザ vimrc: $HOME/.vimrc
 ユーザ exrc: $HOME/.exrc
   省略時の $VIM: /usr/share/vim
コンパイル: i386-redhat-linux-gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pipe 
-m32 -march=i386 -mtune=pentium4 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64   
-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING  -pipe 
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 
-I/usr/include/gdbm  -I/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE  
-I/usr/include/python2.3 -pthread
リンク: i386-redhat-linux-gcc   -Wl,-E 
-Wl,-rpath,/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE   -L/usr/local/lib 
-o vim   -lncurses -lselinux  -lacl -lgpm -Wl,-E 
-Wl,-rpath,/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE  -L/usr/local/lib 
/usr/lib/perl5/5.8.5/i386-linux-thread-multi/auto/DynaLoader/DynaLoader.a 
-L/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE -lperl -lutil -lc 
-L/usr/lib/python2.3/config -lpython2.3 -lutil -lm -Xlinker -export-dynamic

-- 
Dr Bean  Management is doing things right; 
 Leadership is doing the right things.
 --Peter Drucker


Re: Sudden problem with: exe set listchars=tab:\xbb\xb7,trail:\xb7

2006-07-13 Thread James Vega
On Fri, Jul 14, 2006 at 02:29:49AM +0300, Yakov Lerner wrote:
 I always had this line in my vimrc:
   exe set listchars=tab:\xbb\xb7,trail:\xb7
 (It is equivalent to set listchars=tab:»·,trail:·)
 Suddenly his line stopped working. (I didn't change it)
 It assigns now empty value to listchars:
set listchars?
listchars=tab:,trail:
 
 Command L=line  :set listchars=tab:»·,trail:·
 stopped to work, too.
 It prints E474: Invalid argument: listchars=tab:»·,trail:·
 
 What can be causing this ?

It sounds like you're running Vim in an environment that doesn't
understand those characters.  You'll probably want to check what
'encoding' is.

James
-- 
GPG Key: 1024D/61326D40 2003-09-02 James Vega [EMAIL PROTECTED]


signature.asc
Description: Digital signature


R: matchit doesn't work for php

2006-07-13 Thread Cesar Romani

 -Messaggio originale-
 Da: Benji Fisher [mailto:[EMAIL PROTECTED]
 Inviato: giovedì 13 luglio 2006 15.35
 A: vim
 Cc: Dan Sharp
 Oggetto: Re: matchit doesn't work for php
 
 On Thu, Jul 13, 2006 at 06:42:43AM +0200, Cesar Romani wrote:
 
  In the following function the bracket at 3 doesn't match the bracket at
 17
  And the bracket at 5 doesn't match the bracket at 8
 
   1 ?php
   2   function test1($a,$b,$c,$d,$e,$f)
   3   {
   4 if($e=='hola')
   5 {
   6   if($f=='') $f='1000';
   7   $s='{'.$d.':'.$f.'}amigo';
   8 }
   9 else
  10 {
  11   $s='{'.$d.':'.$f.'}amiga';
  12 }
  13 $this-s=$s;
  14 $this-a=$a;
  15 $this-b=$b;
  16 $this-c=$c;
  17   }
  18 ?
 
  Many thanks in advance.
 
  Cesar
 
  The problem is that { is included in the 'matchpairs' option but
 not in b:match_words.  The matchit script recognizes that { is a
 matching character, but does not have a rule for it, so it defaults to
 the built-in % matching behavior.  You can confirm this with
 
 :normal! %
 
  The solution is to add '{:}' to b:match_words ; probably also '(:)'
 and '[:]' while you are at it.  Also, I notice that ftplugin/php.vim
 :source's ftplugin/html.vim and so inherits the HTML setting of
 b:match_skip .  I think that PHP would do better with the default skip
 behavior, so it should :unlet this variable.
 
  I am cc'ing the maintainer of ftplugin/php.vim .
 
 HTH   --Benji Fisher

Thanks a lot, it works but I also notice that else if is not part of the
matching, although else if is a valid expression in php:
It matches if, else, elseif
but it doesn't match if, else, else if
How can I include else if in the matching?
Many thanks in advance.

Cesar