Re: non-latin characters aren't displayed correctly in Windows menu
Mojca Miklavec wrote: Hello, I translated the menus for gvim and wanted to use them under windows, but the non-latin characters simply don't show in the menu (other characters are shown instead: squares š and ž and some other character for č). All other programs under Windows work fine, the encoding should also be OK (If I rename the Russian file to menu_sl_si.utf-8.vim, I only get question marks in menu, but I saw other cyrillic programs running on the same computer without any problems as well). I suspect that Vim might be asking Windows for Western European font for the menu. I'm not sure about it, but in any case it's a bit weird. Is there any remedy for it? Any hints would be appreciated, Mojca Miklavec You must make sure that you have: - an 'encoding' which includes the non-Latin characters you want to use - (in console Vim) a terminal code page which includes them - (in gvim) a 'guifont' which has the glyphs for them. Check 'encoding' and 'guifont' by means of :verbose set encoding? guifont? "Renaming" the file to menu_sl_si.utf-8.vim (as with "rename" or "copy" in a Dos shell, "mv" or "cp" in a Unix shell) probably won't be OK because Vim will interpret the file data differently. You need to: 1. make sure that 'encoding' is set to utf-8. If it isn't, fist set 'termencoding' to the old value of 'encoding' (as it is immediately after loading, before any script or command-line ex-command changes it) then set 'encoding' to utf-8. You can do this in a script (e.g. in your vimrc) by means of if &termencoding == "" let &termencoding = &encoding endif set encoding=utf-8 2. edit the file (under its "old" name) and check that it is displayed correctly. You may need to use ++enc= in the :edit command to specify the current 'fileencoding' for the file. 3. check that there is a line "scriptencoding utf-8" near the top of the file, before the first non-Latin character 4. save the file with ":saveas ++enc=utf-8 ~/.vim/lang/menu_sl_si.utf-8.vim" (on Unix) or ":saveas ++enc=utf-8 ~/vimfiles/lang/menu_sl_si.utf-8.vim" (on Windows) (without hte quotes in either case). See http://vim.sourceforge.net/tips/tip.php?tip_id=246 :help ++opt :help :scriptencoding Best regards, Tony.
Re: Problem with example in :help complete()
Gerald Lai wrote: On Sun, 11 Jun 2006, A.J.Mechelynck wrote: Gerald Lai wrote: Hi all, [On Windows Vim 7.0, binary at ftp://ftp.vim.org/pub/vim/pc/gvim70.exe] I'm having trouble getting the example in :help complete() to work. When I hit in Insert mode, I get this: Error detected while processing function ListMonths: line 1: E523: Not allowed here I have :set nosecure. Having this instead fixes the problem: inoremap =ListMonths() Looks like a bug. I wasn't sure if this has been fixed. -- Gerald Looks to me like a documentation bug. I believe you got it right, and the helpfile got it wrong. Best regards, Tony. Does this mean that isn't allowed for complete()? It mentioned at the top of ":help complete()" that both :map- and = were allowed. Isn't imap MyFunction() and imap =MyFunction() pretty much the same? Or at the very least, the same in terms of security (see :help E523)? -- Gerald Sorry, the in the given example had escaped me. They /ought to/ be synonymous, but the = mechanism is older; is new in version 7, which means perhaps it hasn't yet got all its bugs ironed out. ":help E523" is the same as ":help 'secure'". Are you sure this option isn't set unbeknownst to you? When the error happens, what does ":verbose set secure?" (without the quotes but with the question mark) reply? If it does return "nosecure" then I guess it's a bug. Best regards, Tony.
Re: Problem with example in :help complete()
On Mon, 12 Jun 2006, A.J.Mechelynck wrote: Gerald Lai wrote: On Sun, 11 Jun 2006, A.J.Mechelynck wrote: Gerald Lai wrote: Hi all, [On Windows Vim 7.0, binary at ftp://ftp.vim.org/pub/vim/pc/gvim70.exe] I'm having trouble getting the example in :help complete() to work. When I hit in Insert mode, I get this: Error detected while processing function ListMonths: line 1: E523: Not allowed here I have :set nosecure. Having this instead fixes the problem: inoremap =ListMonths() Looks like a bug. I wasn't sure if this has been fixed. -- Gerald Looks to me like a documentation bug. I believe you got it right, and the helpfile got it wrong. Best regards, Tony. Does this mean that isn't allowed for complete()? It mentioned at the top of ":help complete()" that both :map- and = were allowed. Isn't imap MyFunction() and imap =MyFunction() pretty much the same? Or at the very least, the same in terms of security (see :help E523)? -- Gerald Sorry, the in the given example had escaped me. They /ought to/ be synonymous, but the = mechanism is older; is new in version 7, which means perhaps it hasn't yet got all its bugs ironed out. ":help E523" is the same as ":help 'secure'". Are you sure this option isn't set unbeknownst to you? When the error happens, what does ":verbose set secure?" (without the quotes but with the question mark) reply? If it does return "nosecure" then I guess it's a bug. Yes, it does return "nosecure". Everything unchanged, when I tried the = version, it works. It looks like a bug from my side. Do you notice the same? Anybody else? -- Gerald
Re: Problem with example in :help complete()
Gerald Lai wrote: On Mon, 12 Jun 2006, A.J.Mechelynck wrote: Gerald Lai wrote: On Sun, 11 Jun 2006, A.J.Mechelynck wrote: Gerald Lai wrote: Hi all, [On Windows Vim 7.0, binary at ftp://ftp.vim.org/pub/vim/pc/gvim70.exe] I'm having trouble getting the example in :help complete() to work. When I hit in Insert mode, I get this: Error detected while processing function ListMonths: line 1: E523: Not allowed here I have :set nosecure. Having this instead fixes the problem: inoremap =ListMonths() Looks like a bug. I wasn't sure if this has been fixed. -- Gerald Looks to me like a documentation bug. I believe you got it right, and the helpfile got it wrong. Best regards, Tony. Does this mean that isn't allowed for complete()? It mentioned at the top of ":help complete()" that both :map- and = were allowed. Isn't imap MyFunction() and imap =MyFunction() pretty much the same? Or at the very least, the same in terms of security (see :help E523)? -- Gerald Sorry, the in the given example had escaped me. They /ought to/ be synonymous, but the = mechanism is older; is new in version 7, which means perhaps it hasn't yet got all its bugs ironed out. ":help E523" is the same as ":help 'secure'". Are you sure this option isn't set unbeknownst to you? When the error happens, what does ":verbose set secure?" (without the quotes but with the question mark) reply? If it does return "nosecure" then I guess it's a bug. Yes, it does return "nosecure". Everything unchanged, when I tried the = version, it works. It looks like a bug from my side. Do you notice the same? Anybody else? -- Gerald I see the bug, using VIM - Vi IMproved 7.0 (2006 May 7, compiled Jun 4 2006 08:37:52) Included patches: 1-17 Compiled by [EMAIL PROTECTED] Huge version with GTK2 GUI. Features included (+) or not (-): [...] Best regards, Tony.
Re: reltime() low part incorrect in win32?
On 6/12/06, Eric Arnold <[EMAIL PROTECTED]> wrote: I'm trying to understand what I'm seeing with the msec timing on win32 (cygwin). Inside the debugger, I'm seeing: (gdb) p tm_delta $1 = {u = {LowPart = 2434313347, HighPart = 896}, {LowPart = 2434313347, HighPart = 896}, QuadPart = 3850725010563} (gdb) n 180 n1 = tm_delta.HighPart; (gdb) 181 n2 = tm_delta.LowPart; (gdb) p n1 $4 = 895 (gdb) p n2 $2 = -1860653949 And in Vim: :echo reltime() [895, -162159878] So is this a bug? Internally, the low part of theproftime_T structure is positive, and it shows up externally as negative. I checked, and as far as I can tell, the LowPart is a win32 LARGE_INTEGER, which is 8 bytes, which is trying to be stuffed into a "long" which is 4 bytes. I think the right answer is a "double" It's 64-bit integer (long long), not double. Yakov
Re: missing functions in visincr.vim [Was: Re: Changing a long list of entries with corresponding index]
Charles E Campbell Jr wrote: Gerald Lai wrote: I have a new question: When trying to do :IDMY, I find that I am missing both these functions Jul2Cal() Cal2Jul() AFAIK, there doesn't seem to be any extra required plugin file to run visincr.vim. Is something missing? Yes -- both my website and the vim.sf.net page mention that if you want to use the calendrical incrementing that you need calutil.vim, which is available at my website: http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs (see "Calendar Utilities") Regards, Chip Campbell
Re: Simple move/rename command with cursor placement, howto?
On Sat, Jun 10, 2006 at 03:50:52PM +0200, A.J.Mechelynck wrote: > Marc Weber wrote: > >>Yakov > >> > >How would you implement bash Ctrl-k behaviour ? Delete from cursor till > >the end of line? > > > >noremap : q:i > > > >? ;-) > > > In Normal mode, D (shift-d) deletes from cursor to end-of-line (with a > count: on lines including the current one). > > See > :help D If you want to do the same thing in Insert mode, try :imap lC It is not perfect, since it dumps you into Normal mode if you use it when you are already at the end of the line. If you set 'insertmode', then use CTRL-\ CTRL-N instead of ESC: :imap lC (This will work whether or not 'insertmode' is set.) HTH --Benji Fisher
negative match pattern, again
I need to match lines using g// (not v//); those lines having 'foo' and NOT having /)\s*;/ anywhere in the line. How do I write such regex. I think I need to use \& ^.*foo\&^XXX$ and then put, in place of XXX, the pattern that matches anything not containing /)\s*;/. How do I express it in vim. Yakov I'd write \([^)]\|)\S\|)\s*[^;]\) failing other things.
Re: negative match pattern, again
I need to match lines using g// (not v//); those lines having 'foo' and NOT having /)\s*;/ anywhere in the line. How do I write such regex. Well, there are several ways to go about it. One would be to use Dr. Chip's "logipat" script: http://vim.sourceforge.net/scripts/script.php?script_id=1290 Another would be to use something like :g/foo/if getline(".")!~'blah' | print getline(".") | endif which would search for lines that do contain "foo", but don't contain "blah". I don't know about using the \& atom. There might be a solution with that as well, but for negating matters, it becomes trickier. -tim
Re: negative match pattern, again
On Mon, Jun 12, 2006 at 02:42:18PM +, Yakov Lerner wrote: > I need to match lines using g// (not v//); those lines having > 'foo' and NOT having /)\s*;/ anywhere in the line. How do I write such > regex. > > I think I need to use \& > ^.*foo\&^XXX$ > and then put, in place of XXX, the pattern that > matches anything not containing /)\s*;/. How do I express it in vim. > > Yakov > > I'd write \([^)]\|)\S\|)\s*[^;]\) failing other things. How about preceding 'foo' with '\(...\)\@
Positioning on a given char offset
Hi, I have this problem: a program of mine is giving me error positions based on the file offset and not the line containing the error. Eg. it does not warn me about an error on line "12", but at the "char 2032" Is there any command in Vim to position to that char offset? Thanks, Fabio
Re: negative match pattern, again
On 6/12/06, Tim Chase <[EMAIL PROTECTED]> wrote: > I need to match lines using g// (not v//); those lines having > 'foo' and NOT having /)\s*;/ anywhere in the line. How do I > write such regex. Well, there are several ways to go about it. One would be to use Dr. Chip's "logipat" script: http://vim.sourceforge.net/scripts/script.php?script_id=1290 LogiPat does wonders. Thanks. For the record, :echo LogiPat('"foo"&!"bar"') produces: \%(.*foo.*\&^\%(\%(bar\)[EMAIL PROTECTED])*$\) Yakov
Re: Simple move/rename command with cursor placement, howto?
Benji Fisher wrote: On Sat, Jun 10, 2006 at 03:50:52PM +0200, A.J.Mechelynck wrote: Marc Weber wrote: Yakov How would you implement bash Ctrl-k behaviour ? Delete from cursor till the end of line? noremap : q:i ? ;-) In Normal mode, D (shift-d) deletes from cursor to end-of-line (with a count: on lines including the current one). See :help D If you want to do the same thing in Insert mode, try :imap lC It is not perfect, since it dumps you into Normal mode if you use it when you are already at the end of the line. If you set 'insertmode', then use CTRL-\ CTRL-N instead of ESC: :imap lC (This will work whether or not 'insertmode' is set.) HTH --Benji Fisher In Insert mode, D should do it, and may. (The latter may depend on your 'keymodel' setting.) (Ctrl-O works regardless of 'insertmode' and doesn't take you out of Insert mode.) Best regards, Tony.
Re: Positioning on a given char offset
Hi Fabio > Eg. it does not warn me about an error on line "12", but at the "char 2032" > > Is there any command in Vim to position to that char offset? > Maybe :2032go ? With kind regards Mathias
Re: Positioning on a given char offset
Fabio Rotondo wrote: Hi, I have this problem: a program of mine is giving me error positions based on the file offset and not the line containing the error. Eg. it does not warn me about an error on line "12", but at the "char 2032" Is there any command in Vim to position to that char offset? Thanks, Fabio :go 2032 (with colon), or 2032go (without colon) Requires +byte_offset feature, i.e., has("byte_offset") must return a nonzero value, normally 1. This means "Normal", "Big" or "Huge" features. see ":help go" HTH, Tony.
Re: Positioning on a given char offset
I have this problem: a program of mine is giving me error positions based on the file offset and not the line containing the error. Eg. it does not warn me about an error on line "12", but at the "char 2032" Is there any command in Vim to position to that char offset? If the data is on one line, the pipe command takes a column offset, so in normal mode, just use 2032| (that's "two zero three two pipe") A fabulous feature when you're dealing with data where columns matter (as in column-delimited data files) that drives me nuts when I don't have it in other editors. Score yet one more point for vim. :) If the data is *not* all on one line, you can use "[count]go" in normal mode, or ":[count]go" in Ex mode to go to the particular byte-offset in the file. So in your case, you can just use 2032go or :2032go or :go 2032 You can learn more at :help bar :help :go -tim
Re: negative match pattern, again
Yakov Lerner wrote: I need to match lines using g// (not v//); those lines having 'foo' and NOT having /)\s*;/ anywhere in the line. How do I write such regex. I think I need to use \& ^.*foo\&^XXX$ and then put, in place of XXX, the pattern that matches anything not containing /)\s*;/. How do I express it in vim. Yakov I'd write \([^)]\|)\S\|)\s*[^;]\) failing other things. May I suggest that you try LogiPat out: http://vim.sourceforge.net/scripts/script.php?script_id=1290 or at http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs (see "LogiPat") (as always, my website has the most up-to-date version) In this case, :echo LogiPat('"foo" & !")\s*;') yields \%(.*foo.*\&^\%(\%()\s*;\)[EMAIL PROTECTED])*$\) Regards, Chip Campbell
Re: negative match pattern, again
On 6/12/06, Benji Fisher <[EMAIL PROTECTED]> wrote: On Mon, Jun 12, 2006 at 02:42:18PM +, Yakov Lerner wrote: > I need to match lines using g// (not v//); those lines having > 'foo' and NOT having /)\s*;/ anywhere in the line. How do I write such > regex. > > I think I need to use \& > ^.*foo\&^XXX$ > and then put, in place of XXX, the pattern that > matches anything not containing /)\s*;/. How do I express it in vim. > > Yakov > > I'd write \([^)]\|)\S\|)\s*[^;]\) failing other things. How about preceding 'foo' with '\(...\)\@ Benji, Im not sure the post-foo part works. I think it will give the false match whenever it something after foo that does not match )\s*;. This is not what I wanted. Yakov
omni completion, calling different types
I'm using the omni completion so far on my php scripts and i'm wondering if there are ways i can call different sets of data with different key strokes. ctrl-x+ctrl+o will bring up everything and display everything and will open up a preview window that has info if a function is called with parameters. How do i get the menu that comes up to display the parameters as well? They come up in the preview window just fine just wondering if i can see them in the drop down menu. Also, everytime i start omni completion with ctrl-x+ctrl+o does it research the file again and display everything including the new stuff i may have typed? If so is there a quicker way to see functions with the parameters without reloading the file? ctrl+n will bring up functions but will not update the preview window. Also is there a way that i can just call php functions with parameters and not see functions/classes/variables in the file i'm editing? Also the reverse say i would like to only see functions/classes/variables in the current file or say just the variables? Thanks
Re: negative match pattern, again
On Mon, 12 Jun 2006, Yakov Lerner wrote: On 6/12/06, Tim Chase <[EMAIL PROTECTED]> wrote: > I need to match lines using g// (not v//); those lines having > 'foo' and NOT having /)\s*;/ anywhere in the line. How do I > write such regex. Well, there are several ways to go about it. One would be to use Dr. Chip's "logipat" script: http://vim.sourceforge.net/scripts/script.php?script_id=1290 LogiPat does wonders. Thanks. For the record, :echo LogiPat('"foo"&!"bar"') produces: \%(.*foo.*\&^\%(\%(bar\)[EMAIL PROTECTED])*$\) Yakov In addition to the regex above, you can also do: /^\%(.*)\s*;\)[EMAIL PROTECTED] It's a little shorter, and probably a little faster since the LogiPat regex does a \%(..\)* for every character position of the line. The speed is evident for a long line. It follows the general form of a negative line search for embedded : /^\%(.*[.*][.*]\)[EMAIL PROTECTED] For example, to match a line that contains "foo" but does not contain "bar" between "big" and "tummy": /\%(.*big.*bar.*tummy\)[EMAIL PROTECTED] HTH :) -- Gerald
Re: negative match pattern, again
On Mon, 12 Jun 2006, Gerald Lai wrote: On Mon, 12 Jun 2006, Yakov Lerner wrote: On 6/12/06, Tim Chase <[EMAIL PROTECTED]> wrote: > I need to match lines using g// (not v//); those lines having > 'foo' and NOT having /)\s*;/ anywhere in the line. How do I > write such regex. Well, there are several ways to go about it. One would be to use Dr. Chip's "logipat" script: http://vim.sourceforge.net/scripts/script.php?script_id=1290 LogiPat does wonders. Thanks. For the record, :echo LogiPat('"foo"&!"bar"') produces: \%(.*foo.*\&^\%(\%(bar\)[EMAIL PROTECTED])*$\) Yakov In addition to the regex above, you can also do: /^\%(.*)\s*;\)[EMAIL PROTECTED] It's a little shorter, and probably a little faster since the LogiPat regex does a \%(..\)* for every character position of the line. The speed is evident for a long line. It follows the general form of a negative line search for embedded : /^\%(.*[.*][.*]\)[EMAIL PROTECTED] For example, to match a line that contains "foo" but does not contain "bar" between "big" and "tummy": /\%(.*big.*bar.*tummy\)[EMAIL PROTECTED] Sorry, I missed the ^ anchor: /^\%(.*big.*bar.*tummy\)[EMAIL PROTECTED] -- Gerald
Re: negative match pattern, again
On 6/12/06, Gerald Lai <[EMAIL PROTECTED]> wrote: On Mon, 12 Jun 2006, Gerald Lai wrote: > On Mon, 12 Jun 2006, Yakov Lerner wrote: > >> On 6/12/06, Tim Chase <[EMAIL PROTECTED]> wrote: >>> > I need to match lines using g// (not v//); those lines having >>> > 'foo' and NOT having /)\s*;/ anywhere in the line. How do I >>> > write such regex. >>> >>> Well, there are several ways to go about it. One would be to use >>> Dr. Chip's "logipat" script: >>> >>> http://vim.sourceforge.net/scripts/script.php?script_id=1290 >> >> LogiPat does wonders. Thanks. >> >> For the record, >>:echo LogiPat('"foo"&!"bar"') >> produces: >>\%(.*foo.*\&^\%(\%(bar\)[EMAIL PROTECTED])*$\) >> >> Yakov > > In addition to the regex above, you can also do: > > /^\%(.*)\s*;\)[EMAIL PROTECTED] > > It's a little shorter, and probably a little faster since the LogiPat > regex does a \%(..\)* for every character position of the line. The > speed is evident for a long line. > > It follows the general form of a negative line search for embedded > : > > /^\%(.*[.*][.*]\)[EMAIL PROTECTED] > > For example, to match a line that contains "foo" but does not contain > "bar" between "big" and "tummy": > > /\%(.*big.*bar.*tummy\)[EMAIL PROTECTED] Sorry, I missed the ^ anchor: /^\%(.*big.*bar.*tummy\)[EMAIL PROTECTED] Is the trailing .* necessary there ? Why ? Yakov
Re: negative match pattern, again
On Mon, 12 Jun 2006, Yakov Lerner wrote: On 6/12/06, Gerald Lai <[EMAIL PROTECTED]> wrote: On Mon, 12 Jun 2006, Gerald Lai wrote: > On Mon, 12 Jun 2006, Yakov Lerner wrote: > >> On 6/12/06, Tim Chase <[EMAIL PROTECTED]> wrote: >>> > I need to match lines using g// (not v//); those lines having >>> > 'foo' and NOT having /)\s*;/ anywhere in the line. How do I >>> > write such regex. >>> >>> Well, there are several ways to go about it. One would be to use >>> Dr. Chip's "logipat" script: >>> >>> http://vim.sourceforge.net/scripts/script.php?script_id=1290 >> >> LogiPat does wonders. Thanks. >> >> For the record, >>:echo LogiPat('"foo"&!"bar"') >> produces: >>\%(.*foo.*\&^\%(\%(bar\)[EMAIL PROTECTED])*$\) >> >> Yakov > > In addition to the regex above, you can also do: > > /^\%(.*)\s*;\)[EMAIL PROTECTED] > > It's a little shorter, and probably a little faster since the LogiPat > regex does a \%(..\)* for every character position of the line. The > speed is evident for a long line. > > It follows the general form of a negative line search for embedded > : > > /^\%(.*[.*][.*]\)[EMAIL PROTECTED] > > For example, to match a line that contains "foo" but does not contain > "bar" between "big" and "tummy": > > /\%(.*big.*bar.*tummy\)[EMAIL PROTECTED] Sorry, I missed the ^ anchor: /^\%(.*big.*bar.*tummy\)[EMAIL PROTECTED] Is the trailing .* necessary there ? Why ? Nope, not necessary for :g//. I left it there for hlsearch appeal ;) HTH. -- Gerald
Re: negative match pattern, again
Gerald Lai wrote: On Mon, 12 Jun 2006, Gerald Lai wrote: On Mon, 12 Jun 2006, Yakov Lerner wrote: On 6/12/06, Tim Chase <[EMAIL PROTECTED]> wrote: > I need to match lines using g// (not v//); those lines having > 'foo' and NOT having /)\s*;/ anywhere in the line. How do I > write such regex. Well, there are several ways to go about it. One would be to use Dr. Chip's "logipat" script: http://vim.sourceforge.net/scripts/script.php?script_id=1290 LogiPat does wonders. Thanks. For the record, :echo LogiPat('"foo"&!"bar"') produces: \%(.*foo.*\&^\%(\%(bar\)[EMAIL PROTECTED])*$\) Yakov In addition to the regex above, you can also do: /^\%(.*)\s*;\)[EMAIL PROTECTED] It's a little shorter, and probably a little faster since the LogiPat regex does a \%(..\)* for every character position of the line. The speed is evident for a long line. It follows the general form of a negative line search for embedded : /^\%(.*[.*][.*]\)[EMAIL PROTECTED] For example, to match a line that contains "foo" but does not contain "bar" between "big" and "tummy": /\%(.*big.*bar.*tummy\)[EMAIL PROTECTED] Sorry, I missed the ^ anchor: /^\%(.*big.*bar.*tummy\)[EMAIL PROTECTED] Hello! These two regex's produce different results; I'm using foo and bar instead of foo and ")\s*;", because its more human readable... To see the results, use: vim tst :set hls :so pat1 :so pat2 (also, use a fixed font to see this properly in the email) -- --P1--P2- foo * * bar foo junk* * bar junk junk foo* * junk bar foo junk bar* bar junk foo -- /^\%(bar\)[EMAIL PROTECTED] -- /\%(.*foo.*\&^\%(\%(bar\)[EMAIL PROTECTED])*$\) -- To summarize: Gerald's pattern (P1, pat1) matches the same three that LogiPat's (P2, pat2) does, plus it allows one line that P2 rejects. Regards, Chip Campbell
Re: negative match pattern, again
On Mon, 12 Jun 2006, Charles E Campbell Jr wrote: Gerald Lai wrote: On Mon, 12 Jun 2006, Gerald Lai wrote: On Mon, 12 Jun 2006, Yakov Lerner wrote: On 6/12/06, Tim Chase <[EMAIL PROTECTED]> wrote: > I need to match lines using g// (not v//); those lines having > 'foo' and NOT having /)\s*;/ anywhere in the line. How do I > write such regex. Well, there are several ways to go about it. One would be to use Dr. Chip's "logipat" script: http://vim.sourceforge.net/scripts/script.php?script_id=1290 LogiPat does wonders. Thanks. For the record, :echo LogiPat('"foo"&!"bar"') produces: \%(.*foo.*\&^\%(\%(bar\)[EMAIL PROTECTED])*$\) Yakov In addition to the regex above, you can also do: /^\%(.*)\s*;\)[EMAIL PROTECTED] It's a little shorter, and probably a little faster since the LogiPat regex does a \%(..\)* for every character position of the line. The speed is evident for a long line. It follows the general form of a negative line search for embedded : /^\%(.*[.*][.*]\)[EMAIL PROTECTED] For example, to match a line that contains "foo" but does not contain "bar" between "big" and "tummy": /\%(.*big.*bar.*tummy\)[EMAIL PROTECTED] Sorry, I missed the ^ anchor: /^\%(.*big.*bar.*tummy\)[EMAIL PROTECTED] Hello! These two regex's produce different results; I'm using foo and bar instead of foo and ")\s*;", because its more human readable... To see the results, use: vim tst :set hls :so pat1 :so pat2 (also, use a fixed font to see this properly in the email) -- --P1--P2- foo * * bar foo junk* * bar junk junk foo* * junk bar foo junk bar* bar junk foo -- /^\%(bar\)[EMAIL PROTECTED] -- /\%(.*foo.*\&^\%(\%(bar\)[EMAIL PROTECTED])*$\) -- To summarize: Gerald's pattern (P1, pat1) matches the same three that LogiPat's (P2, pat2) does, plus it allows one line that P2 rejects. In the same context, should instead be: /^\%(.*bar\)[EMAIL PROTECTED] and both patterns match the same. -- Gerald
Re: Calling through a function reference with a variable argument list
Bob Hiestand wrote: On 6/2/06, Charles E Campbell Jr <[EMAIL PROTECTED]> wrote: Bob Hiestand wrote: > My question is whether there is a simpler way to pass an unknown > number of arguments from the current function to a function which > accepts a variable-length list of arguments. ...snip... I don't think that does what I wanted, though I may have misunderstood the implications. That converts the arguments into a string representation of a list, which then becomes the single argument to the second function. Looks like I made a mistake. Here's one that does illustrate passing a variable number of arguments along: " -- fun! AFunc(...) let args = string(a:000) let len = strlen(args) let args = strpart(args,1,len-2) echomsg "call BFunc(".args.") a:0=".a:0 exe "call BFunc(".args.")" endfun " -- fun! BFunc(...) echomsg "BFunc sees: a:0=".a:0 echomsg "a:000<".string(a:000).">" endfun " -- echomsg 'AFunc(1):' call AFunc(1) echomsg 'AFunc(1,"a"):' call AFunc(1,"a") echomsg 'AFunc(1,"a",b):' let b="BBB" call AFunc(1,"a",b) The idea is to have a string hold just the arguments, not the list delimiters. The exe squeezes the string together and then executes it. Consequently, the output is: AFunc(1): call BFunc(1) a:0=1 BFunc sees: a:0=1 a:000<[1]> AFunc(1,"a"): call BFunc(1, 'a') a:0=2 BFunc sees: a:0=2 a:000<[1, 'a']> AFunc(1,"a",b): call BFunc(1, 'a', 'BBB') a:0=3 BFunc sees: a:0=3 a:000<[1, 'a', 'BBB']> P So you can see that BFunc is being called with a variable number of arguments depending on whatever AFunc received (look at the BFunc sees: lines) My intention was to create a passthrough function that could call any other function after determining the function to which it would dispatch control (the application here is a general source integration script that would dispatch to the appropriate function specific to the version control system controlling the current file). As it turns out, I was a victim of narrow thinking because I was trying to modify as little as possible of an existing plugin. The correct change was to simply make the dispatch function and the end functions accept a list as the parameter, in which case pass-through becomes trivial. Thank you for looking at this, You're welcome! Chip Campbell
Re: Simple move/rename command with cursor placement, howto?
On Mon, 12 Jun 2006, A.J.Mechelynck wrote: Benji Fisher wrote: On Sat, Jun 10, 2006 at 03:50:52PM +0200, A.J.Mechelynck wrote: Marc Weber wrote: Yakov How would you implement bash Ctrl-k behaviour ? Delete from cursor till the end of line? noremap : q:i ? ;-) In Normal mode, D (shift-d) deletes from cursor to end-of-line (with a count: on lines including the current one). See :help D If you want to do the same thing in Insert mode, try :imap lC It is not perfect, since it dumps you into Normal mode if you use it when you are already at the end of the line. If you set 'insertmode', then use CTRL-\ CTRL-N instead of ESC: :imap lC (This will work whether or not 'insertmode' is set.) HTH --Benji Fisher In Insert mode, D should do it, and may. (The latter may depend on your 'keymodel' setting.) (Ctrl-O works regardless of 'insertmode' and doesn't take you out of Insert mode.) The only (negligible?) downside to D is when the insert cursor is at the end of the line vs. one character before the end of the line. They both delete the last character (if 'virtualedit' option left as default). "cursor to start/end of line deletion nmap "_D imap _"_D See :help "_ HTH. -- Gerald
Re: negative match pattern, again
Gerald Lai wrote: In the same context, should instead be: /^\%(.*bar\)[EMAIL PROTECTED] and both patterns match the same. And so they do! (with your pattern having .* again, which is unnecessary for :g... as you mentioned). Regards, Chip Campbell
Re: Calling through a function reference with a variable argument list
On Mon, 12 Jun 2006 at 4:07pm, Charles E Campbell Jr wrote: > Bob Hiestand wrote: > > > On 6/2/06, Charles E Campbell Jr <[EMAIL PROTECTED]> wrote: > > > >> Bob Hiestand wrote: > >> > >> > My question is whether there is a simpler way to pass an unknown > >> > number of arguments from the current function to a function which > >> > accepts a variable-length list of arguments. > > > > ...snip... > > > > I don't think that does what I wanted, though I may have misunderstood > > the implications. That converts the arguments into a string > > representation of a list, which then becomes the single argument to > > the second function. > > Looks like I made a mistake. Here's one that does illustrate passing a > variable number of arguments along: > > " -- > fun! AFunc(...) > let args = string(a:000) > let len = strlen(args) > let args = strpart(args,1,len-2) > echomsg "call BFunc(".args.") a:0=".a:0 > exe "call BFunc(".args.")" > endfun > > " -- > fun! BFunc(...) > echomsg "BFunc sees: a:0=".a:0 > echomsg "a:000<".string(a:000).">" > endfun > > " -- > echomsg 'AFunc(1):' > call AFunc(1) > > echomsg 'AFunc(1,"a"):' > call AFunc(1,"a") > > echomsg 'AFunc(1,"a",b):' > let b="BBB" > call AFunc(1,"a",b) > > The idea is to have a string hold just the arguments, not the list > delimiters. > The exe squeezes the string together and then executes it. Consequently, > the output is: > > AFunc(1): > call BFunc(1) a:0=1 > BFunc sees: a:0=1 > a:000<[1]> > AFunc(1,"a"): > call BFunc(1, 'a') a:0=2 > BFunc sees: a:0=2 > a:000<[1, 'a']> > AFunc(1,"a",b): > call BFunc(1, 'a', 'BBB') a:0=3 > BFunc sees: a:0=3 > a:000<[1, 'a', 'BBB']> > P > > So you can see that BFunc is being called with a variable number of > arguments depending on whatever AFunc received (look at the > BFunc sees: lines) I don't know if the OP can use a Vim7.0 only solution, but the genutils plugin has a utility to make this possible for prior versions. I have been using this in several places of one of my plugins with no issues. However, if Vim7.0 only solution is acceptable, Vim supports this already with the call() function. " -- fun! AFunc(...) echomsg "call BFunc(".string(a:000).") a:0=".a:0 call call('BFunc', a:000) endfun " -- fun! BFunc(...) echomsg "BFunc sees: a:0=".a:0 echomsg "a:000<".string(a:000).">" endfun -- HTH, Hari > > > > > My intention was to create a passthrough function that could call any > > other function after determining the function to which it would > > dispatch control (the application here is a general source integration > > script that would dispatch to the appropriate function specific to the > > version control system controlling the current file). > > > > As it turns out, I was a victim of narrow thinking because I was > > trying to modify as little as possible of an existing plugin. The > > correct change was to simply make the dispatch function and the end > > functions accept a list as the parameter, in which case pass-through > > becomes trivial. > > > > Thank you for looking at this, > > You're welcome! > Chip Campbell __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Re: non-latin characters aren't displayed correctly in Windows menu
Mojca Miklavec wrote: On 6/12/06, A.J.Mechelynck wrote: Mojca Miklavec wrote: > Hello, > > I translated the menus for gvim and wanted to use them under windows, > but the non-latin characters simply don't show in the menu (other > characters are shown instead: squares š and ž and some other character > for č). > > All other programs under Windows work fine, the encoding should also > be OK (If I rename the Russian file to menu_sl_si.utf-8.vim, I only > get question marks in menu, but I saw other cyrillic programs running > on the same computer without any problems as well). > > I suspect that Vim might be asking Windows for Western European font > for the menu. I'm not sure about it, but in any case it's a bit weird. > > Is there any remedy for it? > > Any hints would be appreciated, > Mojca Miklavec > > > You must make sure that you have: - an 'encoding' which includes the non-Latin characters you want to use - (in console Vim) a terminal code page which includes them What is that? And "console vim" if you mean the one without GUI menus is not always there (I have it one one computer, but not on the other). "Console Vim" is the one without GUI. On Windows a different executable must be used, usually named vim.exe (or possibly something starting in "vim" as in vimd.exe for a debug version etc.); it displays in a Dos Box. On Unix a single executable can be used as a GUI (through X11) or as a console version (displaying on /dev/tty or on xterm, konsole, etc.) depending on how it is invoked. - (in gvim) a 'guifont' which has the glyphs for them. I have that (the default font is OK), but in Menu another font is used (some default Windows font which is the same in all the applications). Check 'encoding' and 'guifont' by means of :verbose set encoding? guifont? encoding=utf-8 Last set from D:\soft\_vimrc guifont= [some parts deleted] 'guifont' empty means some default system font, such as Fixed. IMHO it is not he prettiest but if you're satisfied with it you may stay with it. 3. check that there is a line "scriptencoding utf-8" near the top of the file, before the first non-Latin character It is. 4. save the file with ":saveas ++enc=utf-8 ~/.vim/lang/menu_sl_si.utf-8.vim" (on Unix) or ":saveas ++enc=utf-8 ~/vimfiles/lang/menu_sl_si.utf-8.vim" (on Windows) (without hte quotes in either case). I didn't use that, but it seems to be in UTF-8. I guess that the problem is not related to the vim itself, but rather to the Windows GUI, so the file might work properly on Mac or Linux. I've seen no options to modify the menu font (I did, but I had the impression that that works only in Linux). There is a -menufont {font} command-line option, but from where it is described in the help I fear it is only applicable to X11 (all Unix/Linux versions and possibly some MacOsX versions). AFAIK the font used for menus in Windows is common to all applications and thus outside the reach of gvim. Try the following: gvim -N -u NONE :language messages :set encoding? This will tell you which "language" and "charset" settings are passed by Windows to gvim before any vimrc or other script changes them. If they are not compatible with what you want to display in the menus, you will need to change the "country-specific" settings before starting Windows. I think the settings are to be found in the "international keyboard" widget, probably configured under Control Panel -> Keyboard, then choose a language and keyboard layout from the system tray; but I might be wrong. See http://vim.sourceforge.net/tips/tip.php?tip_id=246 :help ++opt :help :scriptencoding Can please anybody check the attached file? It seems to me that it IS in utf-8, but I might be wrong. I'm only sending the "Tools" menu. Instead of "Skoči nazaj" I see "Skoèi nazaj" and instead of "Pokaži napake" I get "Poka[]i napake", where [] stands for a box. Can anyone get the content right? Thanks a lot, Mojca I don't know the language it's in, but, when I view it in gvim, it sets 'fileencoding' to utf-8 and the contents look like some mixture of English and some Slavic-family language using Latin alphabet with diacritics (mostly c, s and z, all three with caron). If you _see_ it as something else when you _edit_ it, then either you don't have 'encoding' and 'fileencoding' set both to "utf-8", or your 'guifont' lacks some necessary glyphs. If you see it OK when _editing_ but not in the _menus_ then see above about the Windows settings. Best regards, Tony.
Re: negative match pattern, again
> It follows the general form of a negative line search for embedded > : > > /^\%(.*[.*][.*]\)[EMAIL PROTECTED] > > For example, to match a line that contains "foo" but does not contain > "bar" between "big" and "tummy": > > /\%(.*big.*bar.*tummy\)[EMAIL PROTECTED] Learn a lot more about regexp from this post. Thanks! Sorry, I missed the ^ anchor: /^\%(.*big.*bar.*tummy\)[EMAIL PROTECTED] Just a question, why it is necessary to have the ^ anchor? Isn't .* already includes the characters start from the beginning of the line? Sorry if I'm asking a stupid one -- Ed