Re: vim server ? security hole?

2006-07-27 Thread Bram Moolenaar

Marc Weber wrote:

 I did notice that you can do
 su
 gvim
 :echo SERVERNAME
 
 and then using another user
 gvim --servername=GVIMxx --remote-send='!/dowhatyouwant ;-)'
 
 Thus: If you know your admin is using vim you can easily try to get one
 gvim instance to execute arbitrary commands as super user!!
 
 Don't think this shuold be the case by default.
 
 In my case it does what I want but..
 
 Did I miss anything?

Vim uses the X server for communication.  Only users with write access
to the X server can send a message to Vim.  And if you have write
access, you are also able to send keystrokes to another process, thus
you can do anything anyway.  E.g., by sending keystrokes to an xterm in
which a shell is running.

That is, I think it works this way.  Perhaps someone with more detailed
knowledge of X server access restrictions can give a better answer. 

-- 
hundred-and-one symptoms of being an internet addict:
75. You start wondering whether you could actually upgrade your brain
with a Pentium Pro microprocessor 80.  The upgrade works just fine.

 /// 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: vim server ? security hole?

2006-07-27 Thread Nikolai Weibull

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


Vim uses the X server for communication.  Only users with write access
to the X server can send a message to Vim.  And if you have write
access, you are also able to send keystrokes to another process, thus
you can do anything anyway.  E.g., by sending keystrokes to an xterm in
which a shell is running.

That is, I think it works this way.  Perhaps someone with more detailed
knowledge of X server access restrictions can give a better answer.


Actually, you have to explicitly allow the sending of synthetic
keystrokes to an xterm (the allowSendEvents resource).  I don't know,
but perhaps Vim needs to have something similar.

 nikolai


Re: Patch 7.0.040

2006-07-27 Thread Christian J. Robinson
Today (Thu, 27 Jul 2006), Bram Moolenaar wrote:

 Yesterday (Sun, 23 Jul 2006), Bram Moolenaar wrote:
 
 While the return values are now correct, I still can't select the
 last item(s) in an inputlist() when cmdheight  1.
 
 It appears to work just fine for me.  Can you give a specific
 example?
 
  vim -u NONE -g -c set cmdheight=3 \
  -c echo inputlist(['one', 'two', 'three', 'four', 'five'])
 
 Try clicking on five or four and it won't return, but clicking on
 three does.  And I just discovered that since vim in the above
 example is in compatible mode the return values from inputlist()
 are wrong again, as if the patch was never applied.  Either using
 -N or :set nocompatible does correct the return values, but not
 the other problem.
 
 Ah, 'compatible' causes a problem.  Strange combination of using the
 mouse while 'compatible' is set.  But it should work.
 
 I'll put this in the todo list.

Yes, but as I said, there's still a problem even when in
'nocompatible' mode:

 vim -u NONE -Ng -c set cmdheight=3 \
 -c echo inputlist(['one', 'two', 'three', 'four', 'five'])

And try clicking on five or four.

- Chrisitan

-- 
   You can't be everyone's best friend.
Christian J. Robinson [EMAIL PROTECTED] http://infynity.spodzone.com/
   PGP keys: 0x893B0EAF / 0xFB698360   http://infynity.spodzone.com/pgp


Syntax Feature Request

2006-07-27 Thread Peter Hodge
Hello all,

I just want to throw this idea out there as a potential solution to the
problems I am having with the PHP syntax.  It would be helpful to be able to
name sequential 'nextgroups' for regions and matches, so that the syntax will
highlight an area using certain groups in specific order. I.e:

For example, the PHP function preg_replace(), takes 3 arguments like this:

  /* print 'Goodbye name' instead of 'Hello name' */
  $text = 'Hello Peter';
  print preg_replace('/Hello (\w+)/', Goodbye \1, $text);

Preg_replace works just like Vim's substitute() function, except preg_replace
takes the subject as the last argument rather than the first.  There is
actually a major bug in that code sample which A) most people would not notice;
and B) the highlighting in most text editors would only confuse people even
more (I will explain further down).

For preg_replace, the first argument, '/Hello (\w+)/' is a perl-style regular
expression; the second argument is the replacement pattern which may contain
backreferences, and the third argument can be any variable, expression, etc.

Currently I am finding and highlighting the regular expression string like
this:

  syntax keyword pregFunction preg_replace nextgroup=pregOpenParent
  syntax match pregOpenParent /(/ nextgroup=pregString
  syntatx region pregString start=/'/ end=/'/ skip=...

I have a couple of problems with this; first of all, pregOpenParent matches a
lone opening '(', which means the parenthesis errors syntax items (which match
( and ) together to spot errors) will find another ')' seemingly all by itself
at the end of the call to preg_replace() and highlight it as an error.  I would
like to turn pregOpenParent into a region to take care of the closing ')', but
then how do I specify that the first argument (and only the first) to that
function call is a string with a PCRE pattern in it?

Also very important is that I am able to highlight the 2nd argument to
preg_replace using a specific group for Preg replacement strings, because
(!major bug explanation!) in the string Goodbye \1, most people will see the
\1 and think 'backreference', and in fact the best text editors around might
highlight the \1 in a separate color from the rest of the string, and then most
would think 'definitely backreference!', when really it's octal (\x01) and not
a backreference at all.  So for the 2nd argument to preg-replace, I would like
to be able to highlight \1 as an Error so that people might think What's up
with that? and hopefully they will work out that they need to use '\1' or
\\1 instead; at any rate it would be obvious to them that if the
backreference doesn't seem to be working, the \1 is definitely the problem
and they have a good idea where to start investigating.

My hope is that the new highlighting will save people from wasting hours on
PCRE regular expressions; even though I was fairly good with Vim REs when I
started using PHP's preg functions, a single line of code containing a
15-character preg RE would usually take me 10 or 15 minutes to write correctly
because A) I couldn't remember what needed to have a '\' before it and what
didn't, and B) if I had a misplaced '\', the syntax highlighting would not help
me to find it and I had to fiddle with the pattern endlessly to get it working.

So in order to make an effective PHP syntax, I need to be able to do something
like this in Vim:

  syntax keyword preg_replace nextgroup=pregReplaceParents
  syntax region pregReplaceParents matchgroup=Delimiter start=/(/ end=/)/
\ first=pregPattern,phpIdentifier
\ second=phpComma
\ third=pregReplacement,phpIdentifier
\ fourth=phpComma
\ fifth=phpIdentifier,phpString

... so that inside the pregReplaceParents region, Vim would first try and match
a 'pregPattern' or a 'phpIdentifier', followed by a comma, followed by a
'pregReplacement' or a 'phpIdentifier', followed by a comma, followed by a
phpIdentifier or phpString.

An alternative to this which isn't as tidy but might be simpler to implement,
and might be useful elsewhere, is to allow the 'nextgroup' on a syntax cluster:

  syntax keyword preg_replace nextgroup=pregReplaceParents
  syntax region pregReplaceParents matchgroup=Delimiter start=/(/ end=/)/
\ [EMAIL PROTECTED]
  syntax cluster pregReplaceFirst add=pregPattern,phpIdentifier
[EMAIL PROTECTED]
  syntax cluster pregReplaceSecond add=phpComma [EMAIL PROTECTED]
  syntax cluster pregReplaceThird add=pregReplacement,phpIdentifier
[EMAIL PROTECTED]
  syntax cluster pregReplaceFourth add=phpComma [EMAIL PROTECTED]
  syntax cluster pregReplaceFifth add=phpIdentifier,phpString

*end of suggestions*
==

Does anyone else think that one or both of these features might be useful?

Are there any specific plans for the future of Vim's highlighting?

Is there any possibility of these Feature Requests becoming reality, even if I
have to finish learning C and code them myself?  I would really like to push
the PHP 

Re: please, comment my script

2006-07-27 Thread Christian Ebert
* Benji Fisher on Wednesday, July 26, 2006 at 22:58:07 -0400:
 On Tue, Jul 25, 2006 at 12:36:44AM +0400, Pavel Volkovitskiy wrote:
 map C-S :call PySort()CR
 
 How about calling it directly from Visual mode?
 
 :vmap C-S :C-U PySort()CR

For the above: Would

:vmap C-S Esc:PySort()CR

do the same thing?

If no, what is the difference?
If yes, what is the canonical way to do it?

TIA

c
-- 
_B A U S T E L L E N_ lesen!  --- http://www.blacktrash.org/baustellen.html


Re: Search pattern - without keywords

2006-07-27 Thread Marc Weber
On Thu, Jul 27, 2006 at 07:32:48AM +0530, SHANKAR R-R66203 wrote:
 Hi All,
I want to match all the words in a file which are not keywords.
In a verilog code, I want to match all the signal names execpt for
 the keywords.
 
   /\w\+ finds all the words.
   But How do I make vim understand, not to pick up any keyword.

See :h @!
The if then example. (3. one)
This sequence matches any character which doesn't start the then word.
you have to replace any character by any word and then by any keyword..
\(then\)[EMAIL PROTECTED]

Hope this helps

Marc Weber


Re: Clickable error messages

2006-07-27 Thread Marc Weber
 :Robert

See :h quickfix ;)
Brief: 
:compiler perl
:set makeprg=perl 
:make test.pl)
If you want to add options to perl use set makeprg=perl\ --option\ blah
(escape whitespaces)
The quickfix cycle might remove some output.. depending on errorformat.

I was waiting for this question because :!perl foo doesn't do what you
want :)

See also :h compiler

If you don't want to look at scrolling lines try my runinbackground
script.. (http://www.vim.org/scripts/script.php?script_id=1582)

I would also suggest to have some quick glances at :h  topics basic
editing, advanced editing... Much to read.. or hang around in #vim on
irc.freenode.net. You can learn much there...
You don't have to read everything but it should give you an idea of what
is there .. ;)

To took me over a year to learn many features of vim and then think
about how can I really fast open the files I need ... and so on

Just ask again we'll point to corresponding documentation.

Marc


Search (itemized) results using

2006-07-27 Thread Srinivas Rao. M
Hi,
I am trying to get the itemized search results of a given pattern using
:g command. My question is to use the
tip:http://www.vim.org/tips/tip.php?tip_id=227
And display the search results (found in the current file) as we type
the patter on the console.

Let's say i execute the command similar to 

:/search_pattern 
In the results while it is searching can it print, the number of matches
found for that pattern. 
say 30 lines 50 words 100 characters matched be printed at the command
area ?

Is this possible..
regards,
Srini...



Vim: Caught deadly signal HUP

2006-07-27 Thread Kaushal Shriyan

Hi

when i do vi bdc.xml I get the below on the screen

Vim: Caught deadly signal HUP
Vim: Finished.
Hangup

Any clue


Kaushal


args and tabs

2006-07-27 Thread Fabien Meghazi

Hi all,

Another question about tabs. Is it possible to make the command ':args
*' use tabs instead of buffers ? I also wonder if there is a way to
tell vim to use tabs instead of buffers globally, eg: I also want
':vimgrep /foo/ **' to open tabs instead of buffers



--
Fabien Meghazi

Website: http://www.amigrave.com
Email: [EMAIL PROTECTED]
IM: [EMAIL PROTECTED]


spell does not work for doxygen comments version 7

2006-07-27 Thread Carlos Beltran
Hi all,

The integrated spelling of version 7 doesn't seem to work for doxygen
comments like:
/**
 * Helllo Worllld 
 */

I have not figured out how to fix it.

Configuration:
Vim version 7
Microsoft Windows XP

Thank you.

Carlos.





Re: Vim: Caught deadly signal HUP

2006-07-27 Thread Yakov Lerner

On 7/27/06, Kaushal Shriyan [EMAIL PROTECTED] wrote:

Hi

when i do vi bdc.xml I get the below on the screen

Vim: Caught deadly signal HUP
Vim: Finished.
Hangup


Always ? Sometimes ? When you do XYZ in vim ?
When you do XYZ outside of vim ? When you open such-such file
in vim ? That is, under which conditions ?

Plus, what version of vim (:version), and which OS.

Yakov


PCBSD error

2006-07-27 Thread Robin Becker
I'm trying to run GVim on PCBSD-1.2; when I use the icon installed by 
the .pbi everything seems to be ok, but I get this error when I try and 
run gvim from inside a konsole.



** (gvim-bin:7568): CRITICAL **: ascii_glyph_table_init: assertion 
`gui.ascii_glyphs-num_glyphs == sizeof(ascii_chars)' failed



and then the gvim window appears to be gibberish as I think the font is 
off by one.


I would like to run GVim from konsoles as then I can use su to become 
root (or other users) and carry out editing with my favourite editor.


I can run vim from kde consoles, but when I do I seem always to get 
warning messages about about not a terminal even though vim eventually 
seems to run OK.

--
Robin Becker


Re: Another regular expression substitute question

2006-07-27 Thread Mark Woodward
Hi Xiaoshen,

On Wed, 26 Jul 2006 09:27:33 +
Xiaoshen Li [EMAIL PROTECTED] wrote:

 Dear All,
 Thank you very much for all your responses. I am sorry. My file is a 
 little different now. It is like following:
 
 1  data_34.dat pre= -7872.11914060  post= -7812.80517600  diff=
 59.31396460 2  data_5.dat  pre= -7986.76147466  post= -7926.94091800
 diff= 59.82055666 3  data_16.dat pre= -8117.66357420  post=
 -8057.25097700  diff= 60.41259720 4  data_36.dat pre= -7628.28979490
 post= -7564.08691400  diff= 64.20288090 5  data_18.dat pre=
 -8145.31860358  post= -8078.61328100  diff= 66.70532258
 
 How can I use regular expression to get:
 data_34.dat
 data_5.dat
 data_16.dat
 ..
 
 Thank you very much. I greatly appreciate it.
 
 
 


%s/^\A\+\(\S\+\).*/\1/g or
%s/^\H\+\(\S\+\).*/\1/g 

If you just want the data_34, data_5 part
replace \S with \w in either of the above.


see :h /character-classes


cheers,


-- 
Mark


Re: spell does not work for doxygen comments version 7

2006-07-27 Thread hermitte
Hello,


Carlos Beltran [EMAIL PROTECTED] wrote:

 The integrated spelling of version 7 doesn't seem to work for doxygen
 comments like:
 /**
  * Helllo Worllld
  */

 I have not figured out how to fix it.

Michael has fixed his script, but it seems it is only available through CVS.
BTW, I have troubles to browse the CVS repository from the web. I don't know if
anything can be done.

HTH,

--
Luc Hermitte


Re: Vim: Caught deadly signal HUP

2006-07-27 Thread Yakov Lerner

On 7/27/06, Kaushal Shriyan [EMAIL PROTECTED] wrote:

Hi

when i do vi bdc.xml I get the below on the screen

Vim: Caught deadly signal HUP
Vim: Finished.
Hangup


Your vim received signal SIGHUP. This normally
happens when you close ssh session or xterm, or if you kill
vim process with 'kill -HUP'. What did you do to send
SIGHUP signal to vim ?

Yakov


Re: Search (itemized) results using

2006-07-27 Thread Yakov Lerner

On 7/27/06, Srinivas Rao. M [EMAIL PROTECTED] wrote:

Hi,
I am trying to get the itemized search results of a given pattern using
:g command. My question is to use the
tip:http://www.vim.org/tips/tip.php?tip_id=227
And display the search results (found in the current file) as we type
the patter on the console.

Let's say i execute the command similar to

:/search_pattern
In the results while it is searching can it print, the number of matches
found for that pattern.
say 30 lines 50 words 100 characters matched be printed at the command
area ?


Try this:
  :%s/pattern//n
  191 matches on 191 lines

  :help count-items

Yakov


RE: spell does not work for doxygen comments version 7

2006-07-27 Thread Carlos Beltran

Uhm. I see. Thus, Michael's script is cancelling the undercurl
highlighting attributee draw by the spelling function, isn't it?
Sorry, for pointing out the wrong responsible ;).

Many thanks!

Carlos.

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: Thursday, July 27, 2006 2:30 PM
 To: Carlos Beltran
 Cc: vim@vim.org
 Subject: Re: spell does not work for doxygen comments version 7
 
 Hello,
 
 
 Carlos Beltran [EMAIL PROTECTED] wrote:
 
  The integrated spelling of version 7 doesn't seem to work for doxygen
  comments like:
  /**
   * Helllo Worllld
   */
 
  I have not figured out how to fix it.
 
 Michael has fixed his script, but it seems it is only available through
 CVS.
 BTW, I have troubles to browse the CVS repository from the web. I don't
 know if
 anything can be done.
 
 HTH,
 
 --
 Luc Hermitte



Re: PCBSD error

2006-07-27 Thread A.J.Mechelynck

Robin Becker wrote:
I'm trying to run GVim on PCBSD-1.2; when I use the icon installed by 
the .pbi everything seems to be ok, but I get this error when I try and 
run gvim from inside a konsole.



** (gvim-bin:7568): CRITICAL **: ascii_glyph_table_init: assertion 
`gui.ascii_glyphs-num_glyphs == sizeof(ascii_chars)' failed



and then the gvim window appears to be gibberish as I think the font is 
off by one.


I would like to run GVim from konsoles as then I can use su to become 
root (or other users) and carry out editing with my favourite editor.


I can run vim from kde consoles, but when I do I seem always to get 
warning messages about about not a terminal even though vim eventually 
seems to run OK.


I have no problems running Vim in a konsole terminal. What exactly is 
the message you get? Can you identify approximately at which point 
(probably somewhere in your vimrc) it is generated? Maybe your vimrc 
references options not available in your version of Vim?


See
:help has()
:help feature-list
:help exists()
:help Ennn
where nnn is an error number in decimal

HTH,
Tony.


Re: Howto get omnicomplete popup for vimspell suggestions

2006-07-27 Thread A.J.Mechelynck

Srinivas Rao. M wrote:

Hi Vimmers,
I started using the vimspell plug-in from today. I really appreciate
this feature, really working fine for C code comments. Its very
intelligent as it carefully ignore the C code part in spell checking. It
only purifies the comment and strings part of it.

I have a question:

I noticed that z= will open up a new buffer instead of opening a
omni-complete popup. Is this a desired behavior ?.  
-Or- 
Do i have to set some configuration to get the omni-complete popup. Am i

missing somethings here ?

Please tell me what should i do to get the omnicomplete popup for spell
suggestions ?
regards,
Srini...





From where I sit it looks like z= opens neither buffer nor popup, but 
lists the alternatives on the command-line (pushing all windows up out 
of the screen) asking you to either select an entry by number or by 
mouse-clicking, or hit Enter to leave unchanged. This seems easier than 
omnicomplete to me, especially for a long list (filling up the screen 
height): you can select by mouse the same way, but instead of selecting 
by keyboard using Up or Down repeatedly then Enter, here you just 
type in the number next to the entry you want. More economical in terms 
of keystrokes (on a long list).



Best regards,
Tony.


Re: debugging with breakadd

2006-07-27 Thread Charles E Campbell Jr

Benji Fisher wrote:


On Tue, Jul 25, 2006 at 11:14:09AM -0400, Charles E Campbell Jr wrote:
 


Hello!

I was trying :breakadd file 484 */visincr.vim and got

Breakpoint in /home/cec/.vim/autoload/visincr.vim line 484
Entering Debug mode.  Type cont to continue.
/home/cec/.vim/autoload/visincr.vim
line 638: fun! s:Hex2Dec(hex)

The Breakpoint in... line looks right; however, why does the continue line
show line 638?  The Hex2Dec() function is not being called within 20 
lines of

line 484.  And, of course, its not where I wanted to stop and continue from.

Regards,
Chip Campbell
   



That sounds weird.  Maybe you have some other breakpoint defined?

:breaklist

I cannot reproduce this problem with $VIMRUNTIME/optwin.vim .

 

I've since solved the problem I was having with visincr; I admit that 
what with my Decho.vim library
I seldom need to use vim's built-in debugger.   The breakpoint was the 
only one.


Regards,
Chip Campbell



Re: debugging with breakadd

2006-07-27 Thread Charles E Campbell Jr

Hari Krishna Dara wrote:


I have not observed this before, but I don't usually put file
breakpoints. Couple of ideas to try are:
- Try the new :breakadd here command where you want to stop. It might
 work just fine.
- Generate an exception at this line and observe what line number Vim
 will report.

 


I'll have to try out :breakadd here.

Thank you,
Chip Campbell




Re: PCBSD error

2006-07-27 Thread Robin Becker

A.J.Mechelynck wrote:
 Robin Becker wrote:
 I'm trying to run GVim on PCBSD-1.2; when I use the icon installed 
by the .pbi everything seems to be ok, but I get this error when I try 
and run gvim from inside a konsole.



 ** (gvim-bin:7568): CRITICAL **: ascii_glyph_table_init: assertion 
`gui.ascii_glyphs-num_glyphs == sizeof(ascii_chars)' failed



 and then the gvim window appears to be gibberish as I think the font 
is off by one.


 I would like to run GVim from konsoles as then I can use su to 
become root (or other users) and carry out editing with my favourite editor.


 I can run vim from kde consoles, but when I do I seem always to get 
warning messages about about not a terminal even though vim eventually 
seems to run OK.


 I have no problems running Vim in a konsole terminal. What exactly is 
the message you get? Can you identify approximately at which point 
(probably somewhere in your vimrc) it is generated? Maybe your vimrc 
references options not available in your version of Vim?


 See
 :help has()
 :help feature-list
 :help exists()
 :help Ennn
 where nnn is an error number in decimal

I'm running Vim 7.0 with the default rc ie none. The exact message is

Vim: Warning: Output is not to a terminal

I've checked and it's not actually Konsole that causes this. I see the 
same with a standard console or xterm. I believe the message comes very 
early. I think I'm going to try and install Vim from the ports rather 
than rely on the pbi.


As an additional nonsense, when I add a .vimrc in /usr/local/share/vim 
gvim started in Konsole seems to see it, but the one started from the 
installed icon doesn't. I suppose the icon thing is actually some script 
or executed in some special environment.


--
Robin Becker



Re: please, comment my script

2006-07-27 Thread Benji Fisher
On Thu, Jul 27, 2006 at 09:34:59AM +0200, Christian Ebert wrote:
 * Benji Fisher on Wednesday, July 26, 2006 at 22:58:07 -0400:
  On Tue, Jul 25, 2006 at 12:36:44AM +0400, Pavel Volkovitskiy wrote:
  map C-S :call PySort()CR
  
  How about calling it directly from Visual mode?
  
  :vmap C-S :C-U PySort()CR
 
 For the above: Would
 
 :vmap C-S Esc:PySort()CR
 
 do the same thing?
 
 If no, what is the difference?
 If yes, what is the canonical way to do it?
 
 TIA

 Since we are both using :vmap and not :vnoremap, we are both
vulnerable to unexpected results from user-defined mappings.

 If the user has 'insertmode' set, then Esc will go to Insert mode
rather than Normal mode,  You can use C-\C-N to be safe.

 Your version can be abbreviated, if you keep your :map , to

:vmap script C-S C-\C-NC-S

Check the docs before relying on this, but IIRC :vmap and :vnoremap
behave the same if you add script .

 Other than these minor differences, my original suggestion and
yours should do exactly the same things.

HTH --Benji Fisher


get the umlauts right

2006-07-27 Thread Tobias Herp
Hi, fellow vimmers,

I' struggling for quite a while now to get the character encoding right; I'd 
like vim to guess right, or at least to know which magical comment I could use 
to force vim to use the correct encoding settings. This is an everyday problem 
to me, since I work on Windows (different encoding conventions for GUI and 
shell programs!) as well as several Linux machines which are slightly 
differently configured.

Via our web-based bugtracker, I created an example file (attached) which 
contains german umlauts and their Javascript and HTML encodings and should look 
like this:

snip
ä   %E4 auml; (auml)
ö   %F6 ouml; (ouml)
ü   %FC uuml; (uuml)

Ä   %C4 Auml; (Auml)
Ö   %D6 Ouml; (Ouml)
Ü   %DC Uuml; (Uuml)

ß   %DF szlig; (szlig)
/snip

(to cover the case the webmail interface scrambles the HTML entities I repeated 
them in the 4th column without the amp; and ;)

The umlauts are displayed correctly when I open the file with WinXP's notepad 
(which in turn doesn't like the *IX line endings), but vim doesn't get them 
right (Bram's Vim 7.0 on a german WinXP prof, +multi_byte_ime/dyn).

Is there something I can do to make vim guess right, at the very least for this 
document?

Thanks a lot in advance!
-- 
Tobias


msg2308
Description: Binary data


C-U or Esc in :vmap (was: please, comment my script)

2006-07-27 Thread Christian Ebert
* Benji Fisher on Thursday, July 27, 2006 at 13:13:39 -0400:
 On Thu, Jul 27, 2006 at 09:34:59AM +0200, Christian Ebert wrote:
 * Benji Fisher on Wednesday, July 26, 2006 at 22:58:07 -0400:
 :vmap C-S :C-U PySort()CR
 
 For the above: Would
 
 :vmap C-S Esc:PySort()CR
 
 do the same thing?
 
 If no, what is the difference?
 If yes, what is the canonical way to do it?
 
 Since we are both using :vmap and not :vnoremap, we are both
 vulnerable to unexpected results from user-defined mappings.

Yes, I actually use :vnoremap, but concentrated on C-U vs.
Esc.

 If the user has 'insertmode' set, then Esc will go to Insert mode
 rather than Normal mode,  You can use C-\C-N to be safe.

Ah, didn't think of that ... but :help 'insertmode' says:

However, when Esc is used inside a mapping, it behaves like
'insertmode' was not set.  This was done to be able to use the same
mappings with 'insertmode' set or not set.

Interesting though, :help c_Ctrl-\ takes me to c_Ctrl-\_e ...

 Your version can be abbreviated, if you keep your :map , to
 
 :vmap script C-S C-\C-NC-S

Hm. Now I have to try to understand what exactly C-\C-N does
...

 Check the docs before relying on this, but IIRC :vmap and :vnoremap
 behave the same if you add script .

Indeed.

:help :map-script

Note: :map script and :noremap script do the same thing.  The
script overrules the command name.  Using :noremap script is
preferred, because it's clearer that remapping is (mostly) disabled.


The mapping I had in mind goes in fact like so:

:vnoremap script PlugMyscriptDo Esc:call MyscriptDo()CR

I just wanted to know, whether :C-Ucall MyscriptDo()CR as
{rhs} is preferred, faster, or has other advantages.

 Other than these minor differences, my original suggestion and
 yours should do exactly the same things.

Ok. Thanks.

c
-- 
_B A U S T E L L E N_ lesen!  --- http://www.blacktrash.org/baustellen.html


Re: get the umlauts right

2006-07-27 Thread A.J.Mechelynck

Tobias Herp wrote:

Hi, fellow vimmers,

I' struggling for quite a while now to get the character encoding right; I'd 
like vim to guess right, or at least to know which magical comment I could use 
to force vim to use the correct encoding settings. This is an everyday problem 
to me, since I work on Windows (different encoding conventions for GUI and 
shell programs!) as well as several Linux machines which are slightly 
differently configured.

Via our web-based bugtracker, I created an example file (attached) which 
contains german umlauts and their Javascript and HTML encodings and should look 
like this:

snip
ä   %E4 auml; (auml)
ö   %F6 ouml; (ouml)
ü   %FC uuml; (uuml)

Ä   %C4 Auml; (Auml)
Ö   %D6 Ouml; (Ouml)
Ü   %DC Uuml; (Uuml)

ß   %DF szlig; (szlig)
/snip

(to cover the case the webmail interface scrambles the HTML entities I repeated 
them in the 4th column without the amp; and ;)

The umlauts are displayed correctly when I open the file with WinXP's notepad 
(which in turn doesn't like the *IX line endings), but vim doesn't get them 
right (Bram's Vim 7.0 on a german WinXP prof, +multi_byte_ime/dyn).

Is there something I can do to make vim guess right, at the very least for this 
document?

Thanks a lot in advance!


After saving the attachment and loading it in gvim, I see it all right. 
I am using:


VIM - Vi IMproved 7.0 (2006 May 7, compiled Jul 23 2006 22:50:51)
Included patches: 1-42
Compiled by [EMAIL PROTECTED]
Huge version with GTK2-GNOME GUI.  Features included (+) or not (-):
[etc.]

'encoding' is set to utf-8 and the file opening heuristic also sets 
'fileencoding' to utf-8 without BOM. This is weird since the attachment 
header says


Content-Type: text/plain; charset=iso-8859-1

I wonder if Thunderbird converted it to UTF-8 or what.



What does your Vim say on this file in reply to

:verbose set enc? fenc? fencs?

?


Notes:

-- To set 'fileencoding' to something else than what Vim would normally 
expect, use the ++enc option to :edit, see :help ++opt.


-- To force recognition of a file as Unicode (e.g., UTF-8), use 
:setlocal bomb on it; then check that 'fileencoding' is setlocal'ed to 
some Unicode encoding (such as utf-8) and save.


-- To force recognition of a file as not UTF-8 but Latin1 (assuming 
'fileencodings' [plural] is set to ucs-bom,utf-8,latin1), put a number 
of upper-ASCII bytes (bytes 127) near the beginning, maybe in a 
comment. If the file is a text file, you can also use it as weird 
underlining (e.g. underline your main title with a row of  (pounds 
sterling) or of Danish  (slashed O's); then :setlocal fenc=latin1 
and save. The following works well in one of my text files:


-
# zim: set fenc=latin1 nomod : £µ
# zim (not vim) above is intentional
-



Best regards,
Tony.


RE: spell does not work for doxygen comments version 7

2006-07-27 Thread Bram Moolenaar

Carlos Beltran wrote:

 BTW Sourceforge has change its naming policy. It seems that the link
 for the cvs is now: http://vim.cvs.sourceforge.net/vim/ 
 The link in the http://www.vim.org/cvs.php is thus incorrent.

Annoying, SF keeps changing things...  I'll fix the link.

-- 
hundred-and-one symptoms of being an internet addict:
66. You create a homepage with the impression to cure the afflicted...but
your hidden agenda is to receive more e-mail.

 /// 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: spell does not work for doxygen comments version 7

2006-07-27 Thread Bill McCarthy
On Thu 27-Jul-06 4:29pm -0600, Bram Moolenaar wrote:

 Carlos Beltran wrote:

 BTW Sourceforge has change its naming policy. It seems that the link
 for the cvs is now: http://vim.cvs.sourceforge.net/vim/ 
 The link in the http://www.vim.org/cvs.php is thus incorrent.

 Annoying, SF keeps changing things...  I'll fix the link.

CVS hasn't worked here for many months.

I go to C:\vim\vim70_cvs and type:

cvs -z3 up -PdC

I see that the file CVS\root contains:

:pserver:[EMAIL PROTECTED]:/cvsroot/vim

Does that line need to be changed.  If so, to what and do I
need to change all 83 of these root files?

-- 
Best regards,
Bill



Syntax files

2006-07-27 Thread Max Dyckhoff
I finally bit the bullet and wrote some quick scripts to generate syntax
files containing thousands of keywords from the codebase with which I am
working, using ctags and awk. The resulting files are pretty big.

I have placed all the identifiers on a single line with syn keyword
(type) at the beginning. There are two files of keywords (types and
defines/enumerators), which are 250,000 characters and 650,000
characters respectively (we have a load of enumerators apparently!)

The way that I am making use of these files is by sourcing them in
after\syntax\c.vim, which means they are loaded every time I open a
file. This becomes mildly annoying, because the load of the file now
takes 2-3 seconds, thanks to the two massive syn keyword lines.

Is there any way to say for this instance of vim, make use of these
keywords in all .c, .inl, .cpp and .h files, so that I don't need to
resource the files every time I open a new source file? Or even just to
make the sourcing go more quickly?

Additionally, I have seen some standard keywords are being overridden
(for example we have a #define const somewhere in a library, for some
reason). Is there any way to say only make these words keywords of this
type if they haven't been keyworded already?

I'll just say: it is awesome to see all your keywords nicely highlighted
across the codebase :)

Thanks in advance!

Max
--
Max Dyckhoff 
AI Engineer
Bungie Studios



Syntax Feature Request

2006-07-27 Thread Peter Hodge
Hello all,

I just want to throw this idea out there as a potential solution to the
problems I am having with the PHP syntax.  It would be helpful to be able to
name sequential 'nextgroups' for regions and matches, so that the syntax will
highlight an area using certain groups in specific order. I.e:

For example, the PHP function preg_replace(), takes 3 arguments like this:

  /* print 'Goodbye name' instead of 'Hello name' */
  $text = 'Hello Peter';
  print preg_replace('/Hello (\w+)/', Goodbye \1, $text);

Preg_replace works just like Vim's substitute() function, except preg_replace
takes the subject as the last argument rather than the first.  There is
actually a major bug in that code sample which A) most people would not notice;
and B) the highlighting in most text editors would only confuse people even
more (I will explain further down).

For preg_replace, the first argument, '/Hello (\w+)/' is a perl-style regular
expression; the second argument is the replacement pattern which may contain
backreferences, and the third argument can be any variable, expression, etc.

Currently I am finding and highlighting the regular expression string like
this:

  syntax keyword pregFunction preg_replace nextgroup=pregOpenParent
  syntax match pregOpenParent /(/ nextgroup=pregString
  syntatx region pregString start=/'/ end=/'/ skip=...

I have a couple of problems with this; first of all, pregOpenParent matches a
lone opening '(', which means the parenthesis errors syntax items (which match
( and ) together to spot errors) will find another ')' seemingly all by itself
at the end of the call to preg_replace() and highlight it as an error.  I would
like to turn pregOpenParent into a region to take care of the closing ')', but
then how do I specify that the first argument (and only the first) to that
function call is a string with a PCRE pattern in it?

Also very important is that I am able to highlight the 2nd argument to
preg_replace using a specific group for Preg replacement strings, because
(!major bug explanation!) in the string Goodbye \1, most people will see the
\1 and think 'backreference', and in fact the best text editors around might
highlight the \1 in a separate color from the rest of the string, and then most
would think 'definitely backreference!', when really it's octal (\x01) and not
a backreference at all.  So for the 2nd argument to preg-replace, I would like
to be able to highlight \1 as an Error so that people might think What's up
with that? and hopefully they will work out that they need to use '\1' or
\\1 instead; at any rate it would be obvious to them that if the
backreference doesn't seem to be working, the \1 is definitely the problem
and they have a good idea where to start investigating.

My hope is that the new highlighting will save people from wasting hours on
PCRE regular expressions; even though I was fairly good with Vim REs when I
started using PHP's preg functions, a single line of code containing a
15-character preg RE would usually take me 10 or 15 minutes to write correctly
because A) I couldn't remember what needed to have a '\' before it and what
didn't, and B) if I had a misplaced '\', the syntax highlighting would not help
me to find it and I had to fiddle with the pattern endlessly to get it working.

So in order to make an effective PHP syntax, I need to be able to do something
like this in Vim:

  syntax keyword preg_replace nextgroup=pregReplaceParents
  syntax region pregReplaceParents matchgroup=Delimiter start=/(/ end=/)/
\ first=pregPattern,phpIdentifier
\ second=phpComma
\ third=pregReplacement,phpIdentifier
\ fourth=phpComma
\ fifth=phpIdentifier,phpString

... so that inside the pregReplaceParents region, Vim would first try and match
a 'pregPattern' or a 'phpIdentifier', followed by a comma, followed by a
'pregReplacement' or a 'phpIdentifier', followed by a comma, followed by a
phpIdentifier or phpString.

An alternative to this which isn't as tidy but might be simpler to implement,
and might be useful elsewhere, is to allow the 'nextgroup' on a syntax cluster:

  syntax keyword preg_replace nextgroup=pregReplaceParents
  syntax region pregReplaceParents matchgroup=Delimiter start=/(/ end=/)/
\ [EMAIL PROTECTED]
  syntax cluster pregReplaceFirst add=pregPattern,phpIdentifier
[EMAIL PROTECTED]
  syntax cluster pregReplaceSecond add=phpComma [EMAIL PROTECTED]
  syntax cluster pregReplaceThird add=pregReplacement,phpIdentifier
[EMAIL PROTECTED]
  syntax cluster pregReplaceFourth add=phpComma [EMAIL PROTECTED]
  syntax cluster pregReplaceFifth add=phpIdentifier,phpString

*end of suggestions*
==

Does anyone else think that one or both of these features might be useful?

Are there any specific plans for the future of Vim's highlighting?

Is there any possibility of these Feature Requests becoming reality, even if I
have to finish learning C and code them myself?  I would really like to push
the PHP 

Re: Perl::Tags (Was: perlcomplete.vim -- anyone working on this?

2006-07-27 Thread Dr Bean
On Fri, 21 Jul 2006, Hakim Cassimally wrote:

 Have you got PERL5LIB set to look in lib/ and t/ ?
 Module::Locate defaults to looking at @INC.
 You could set this in your environment variables.

Rather than this alternative, I like the next one:

 Of course, it would be nice if Perl::Tags would look at:
   use lib qw(  );
 declarations and add those to where it looks for modules...

I was able to do this with a parser in a subclass of
Perl::Tags::Naive, but it just rewrites @INC.

 By the way, Dr Bean, if you'd like commit access to the
 repo at http://greenokapi.net/svn/code/Perl-Tags/ just
 email me the output of htpasswd and I'll add to the
 auth file :-)

I subclassed Naive with some parsers to tag some Spiffy
things.

What else would it nice to be able to tag? Sometimes I find
myself wanting to know where a method is invoked.

 On 21/07/06, Dr Bean [EMAIL PROTECTED] wrote:
 On Wed, 12 Jul 2006, Dr Bean wrote:

 This autocommand refreshes the tags file when you write, but the
 tags you have last written are the last ones you want to jump
 to, so I don't think it is much use.

 augroup perltags
 au!

 autocmd BufWritePost *.pm,*.pl call s:do_tags(expand('%'))

autocmd BufRead,BufWritePost *.pm,*.pl call s:do_tags(expand('%'))

This is more important, because when you start editing another
file in another buffer you want tags to be created for it.

 augroup END

-- 
Dr Bean  Experience is the best teacher because it 
 gives the test first  the lesson after.
 --From Martin Pauly


Re: Howto get omnicomplete popup for vimspell suggestions

2006-07-27 Thread Srinivas Rao. M
  From where I sit it looks like z= opens neither buffer nor popup, but 
 lists the alternatives on the command-line (pushing all windows up out 
 of the screen) asking you to either select an entry by number or by 
 mouse-clicking, or hit Enter to leave unchanged. This seems easier than 
 omnicomplete to me, especially for a long list (filling up the screen 
 height): you can select by mouse the same way, but instead of selecting 
 by keyboard using Up or Down repeatedly then Enter, here you just 
 type in the number next to the entry you want. More economical in terms 
 of keystrokes (on a long list).
 
 
 Best regards,
 Tony.
 
 

Yes Precisely, I missed it. It is a list of words on the command line.
But in the  usability perspective, user has to shift his eye focus away
from the word he is typing to the left hand top corner of screen(in to
the command line list). This i think is not usability friendly. We can
see some of the usability analysis on UI products mentioned here:
http://www.useit.com

Can we not have a beautiful omni complete feature here, instead of this
long list. I agree it is typing friendly, lesser number of key strokes.
Can we not have a pop-up that opens up just besides the erratic word.

Just putting my views and ideas here.
Thanks for reading it.
regards,
Srini...