Thursday, March 31, 2011

What is supposed to happen if there is an error in a vim script?

> However none of you answered,
> anywhere in the available documentation?
> Not just mentioned in passing by an example!

> Where are the rules for this detailed?

Actually the documentation does describe, in detail, the rules for handling
errors, exceptions, and interrupts -- if the author of a script encloses it in
a ``try'' block. You can find these explanations in the document eval.txt in
Section 8 ``Exception Handling''. You can also use help commands to locate
descriptionfor the ``catch'' ``throw'' and ``finally'' commands within
``try'' and ``endtry'' blocks.

I had to deal with this recently myself when I wrote a few scripts,.
Frankly, I found these rules unnecessarily complex and, well, arcane compared
to error handling in other script languages (e.g., unix shells).

Vim provides a set of rules for the Author of a script to deal with errors,
should he or she choose to do so. However, if the author does not use the
``try'' mechanism - I fear errors are handled -well - however the developers
happened to handle each particular error. Generally, error messages are
displayed and some action may or may not be taken.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

why remap is not working

Hi, All
 
I want to add ";" to the end of line when coding. So, I add the following map in vimrc. however, it's not working for me (if I change to <C-e>, it's OK). Anybody know why? <C-;> is mapped to a special command already?
 
:inoremap <C-;> <C-o>A;

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Regular Expression Help

On Fri, Apr 1, 2011 at 11:53 AM, Terence Monteiro wrote:
/\(\w\+\)\s*=\s*\(\(\\'\|[^']\)*\)'

You'll need a ' after the \s*. Depending on whether you want to capture the single quotes:

\(\w\+\)\s*=\s*'\(\\'\|[^']\)*'

Regards, Terence.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Regular Expression Help

Alessandro,

On Fri, Apr 1, 2011 at 11:05 AM, Alessandro Antonello <antonello.ale@gmail.com> wrote:
Hi, all.

I have a problem building a regular expression for fields in a SQL UPDATE
statement. The SET clause has the format as follows:

field1 = 'value of field1', field2 = 'field\' 2 value'

I have built a regular expression that can split the name of fields from its
values. But when a value has an escaped single-quote the regular expression
fails...

This should work:

/\(\w\+\)\s*=\s*\(\(\\'\|[^']\)*\)'

1. You need to escape the +, (, ), | metacharacters
2. The value part is 0 or more \' or [^'] sequences
 
Regards, Terence.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Regular Expression Help

On 01/04/11 07:35, Alessandro Antonello wrote:
> Hi, all.
>
> I have a problem building a regular expression for fields in a SQL UPDATE
> statement. The SET clause has the format as follows:
>
> field1 = 'value of field1', field2 = 'field\' 2 value'
>
> I have built a regular expression that can split the name of fields from its
> values. But when a value has an escaped single-quote the regular expression
> fails. I know that it fails because I am using the expression [^'] in between
> the parenthesis. But how to fix this?
>
> This is the regular expression I am using:
>
> /(\w+)\s*=\s*(('[^']*'\s*,)|(\d+\s*,))\s*/i
>
> Could someone help me with that?
>
> Alessandro Antonello
>

I think you could use non-greedy matching i.e. .\{-} and end at (or
maybe just before) a single quote not preceded by a backslash (maybe end
the pattern with [^\\]' if there must be at least one character between
the quotes).

See
:help non-greedy
:help /[]


Best regards,
Tony.
--
Loose bits sink chips.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Regular Expression Help

Hi, all.

I have a problem building a regular expression for fields in a SQL UPDATE
statement. The SET clause has the format as follows:

field1 = 'value of field1', field2 = 'field\' 2 value'

I have built a regular expression that can split the name of fields from its
values. But when a value has an escaped single-quote the regular expression
fails. I know that it fails because I am using the expression [^'] in between
the parenthesis. But how to fix this?

This is the regular expression I am using:

/(\w+)\s*=\s*(('[^']*'\s*,)|(\d+\s*,))\s*/i

Could someone help me with that?

Alessandro Antonello

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Finding the correct map

On 03/31/2011 05:01 PM, carlosvillu wrote:
> I came from Textmate and i try to created a map that i was so
> useful for me. When i edit a file in insert mode, i want can
> press <shift>Left /<shift>Rigth for select caracter by
> caracter and <shift><cmd>Left<shift><cmd>Right to select word
> by word. Really I tried, but I don´t make work fine.

Assuming your vim can see that key-sequence (see note below), you
can use

:nnoremap <s-left> v<left>
:nnoremap <s-right> v<right>
:vnoremap <s-left> <left>
:vnoremap <s-right> <right>

which should implement the behavior you expect.

-tim


NOTE: to see if your Vim distinguishes between them, in either
insert-mode or command-line (":"-prompt) mode, you can type
control-V followed by shift-left. Then try the same with
control-V followed by plain-left and see if Vim sees the same
key-sequence. Alternatively in insert-mode, you can prefix the
key-to-check with control-K to see the vim-key-code representation.

:help i_CTRL-V
:help i_CTRL-K

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Finding the correct map

Hi,

I came from Textmate and i try to created a map that i was so
useful for me. When i edit a file in insert mode, i want can press
<shift>Left / <shift>Rigth for select caracter by caracter and
<shift><cmd>Left <shift><cmd>Right to select word by word. Really I
tried, but I don´t make work fine.

I hope that somebody can help me.

Regards,
CARLOS.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Tag jumps and colon

On 2011-03-31, Kim Schulz wrote:
> Hi,
> I use tag jumping with ctags a lot but one thing annoys me.
> In C code when I have a switch case like:
> switch (foo)
> {
> case BAR:
> {
> ....
> }
> }
> I cannot ctrl-leftmouse click the BAR word in order to jump to it. It
> thinks that : (colon) is part of the tag name and hence cannot find it.
> I am sure that there is some setting in vim for this, but I have not
> been able to identify it. So how do I fix this?

That's probably because your 'iskeyword' option contains ":". You
can check that with

:set iskeyword?

That's not the default and it's not normal for C, so if 'iskeyword'
does contain ":", you might first try to find out where that is
being set with

:verbose set iskeyword?

then fix your configuration as required so that that doesn't happen.

You can fix the problem in the short term and further verify that
that is the problem by executing

:set iskeyword-=:

HTH,
Gary

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: about submatch in VIM

On 03/31/2011 12:10 PM, Coiby wrote:
> I want to increase the number in this format "/ddd" by one but also keep
> "/".
> But the following command doesn't work:
> $s/\/\([1-9]\+\)/\/\=submatch(1)-1)/g
> Can anyone give a tip?

In addition to what ZyX's comments (particularly about the "\="
needing to be at the beginning of the replacement), I'd use the
"\zs" to mark the beginning of what I want to replace (which also
allows you to tidy up the regexp by not needing "\(...\)" wrapped
around), and use an alternate delimiter to obviate escaping:

:%s@/\zs[1-9]\+@\=submatch(0)-1@g

A few other things of note:

- the lack of "0" is suspicious, so I expect you mean

[1-9][0-9]* " positive numbers
[0-9]\+ " non-negative numbers

- you say you want "increase" the number, but you subtract 1 from
it (easy fix...just change "-" to "+")

- your initial expression has an extra close-paren that doesn't
seem to have a matching open-paren. That may have been a mis-key
when transcribing.


Hope that gives you both a solution and a bit of understanding
regarding what it's doing.

-tim

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: about submatch in VIM

Reply to message «about submatch in VIM»,
sent 21:10:08 01 April 2011, Friday
by Coiby:

`\=' must be the at the beginning of the replacement string, so you should use
`\="\/".(submatch(1)+1)' (`-1' is `decrease', not `increase'). By the way, you
could have used `\@<=':
$s!/\@<=[1-9]\+!\=submatch(0)+1!g

Original message:
> Hi, everyone!
> I want to increase the number in this format "/ddd" by one but also keep
> "/".
> But the following command doesn't work:
> $s/\/\([1-9]\+\)/\/\=submatch(1)-1)/g
> Can anyone give a tip?
> Thanks!
>
> --
> View this message in context:
> http://vim.1045645.n5.nabble.com/about-submatch-in-VIM-tp4273737p4273737.h
> tml Sent from the Vim - General mailing list archive at Nabble.com.

about submatch in VIM

Hi, everyone!
I want to increase the number in this format "/ddd" by one but also keep
"/".
But the following command doesn't work:
$s/\/\([1-9]\+\)/\/\=submatch(1)-1)/g
Can anyone give a tip?
Thanks!

--
View this message in context: http://vim.1045645.n5.nabble.com/about-submatch-in-VIM-tp4273737p4273737.html
Sent from the Vim - General mailing list archive at Nabble.com.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: call graph functionality

I'm not sure I still get your exact requirements. The latest version of CCTree can load a kernel cscope
database of 280 Mb in about 10 mins, and now you have the option of saving a native cross-ref db
and loading it later; these only take about a couple of mins and you can reuse them (and also, I mentioned
 the next release will cover the loads directly from disk). If you can run multiple sessions of vim, you can load
the database in a session, save it and then load it to memory or trace from disk in any session. That would allow you
to continue your editing in another session; well, yes, it's like manual background processing.

On another note, background processing is something that Vimscript API should natively offer; there is nothing
that can be done inside a plugin to achieve that.


On Wed, Mar 30, 2011 at 9:58 PM, sinbad <sinbad.sinbad@gmail.com> wrote:
hi hari,

i really appreciate your effort on this front.
i guess the only reason the script is not
being used by many hardcore programmers
is it's lack of usability for huge projects.
as it is obvious that you are clearly working
on it to make it better. i would love to give
it a try, but the only reasonable way for it
to become useful is when it gets the capability
to run in background.

cheers


On Mar 30, 9:41 pm, "hari.rangara...@gmail.com"
> Version 1.21 of CCTree allows serialization of loaded cscope databases. So,
> you could run a vim process
> in the background sourcing the script which goes something like:
>
> load_my_cscope.vim:
> :CCTreeLoadDB cscope.out
> :CCTreeSaveXRefDb cctree.out
>
> $ vim -S load_my_cscope.vim
>
> Once it's done, you can load it in your current session with
> :CCTreeLoadXRefDb cctree.out
>
> The second load will take a few minutes usually. I'm currently testing a
> version that allows tracing from disk, requiring
> no load time (If you would like to try that out, let me know).
>
>
>
>
>
>
>
> On Wed, Mar 30, 2011 at 12:35 AM, sinbad <sinbad.sin...@gmail.com> wrote:
> > i was referring to CCTree Plugin in my OP. the problem with that
> > script is it can't be run
> > in background (as none of the vim scripts can), while it is building
> > the call tree,
> > vim will not be available for editing,  this is a big problem if the
> > source files are huge.
> > if vim has this capability in-built (like a pthread running in
> > background) then it will be of
> > useful. btw, i am not looking for any fancy graphical natured call
> > graphs. an ascii tree
> > like the one provided in CCTree will be enough.
>
> > On Mar 30, 12:07 pm, Sasha <sasha.h...@gmail.com> wrote:
> > > I guess you didn't like vim's cscope support (:help cscope) or the
> > > CCTree plugin (http://www.vim.org/scripts/script.php?script_id=2368).
>
> > > I assume you mean you want to generate vector/raster graphical
> > > representations of the call graph. Doing this efficiently and well
> > > realistically requires using a tool built for the purpose (e.g.
> > > codeviz, just for one example:
> >http://www.csn.ul.ie/~mel/projects/codeviz/)
>
> > > Why not find a tool which does the job as you like it, and then map
> > > keys to control that tool from vim?
>
> > > Sasha
>
> > > On Mar 30, 1:32 am, sinbad <sinbad.sin...@gmail.com> wrote:
>
> > > > hi,
>
> > > > i know many of the developers must be using vim to write
> > > > their c programs, but why there isn't an effort to add this
> > > > crucial functionality to vim. some vim scripts are available
> > > > to do exactly this, but they are not efficient and can't run
> > > > in parallel like figuring out function relationship in the
> > > > background.
>
> > > > thanks
>
> > --
> > You received this message from the "vim_use" maillist.
> > Do not top-post! Type your reply below the text you are replying to.
> > For more information, visithttp://www.vim.org/maillist.php

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: What is supposed to happen if there is an error in a vim script?

Andy Wokula wrote:
> Am 31.03.2011 08:38, schrieb Rostyslaw Lewyckyj:
>> IF vim recognizes an error in a script, what does it do?
>> Where are the rules for this detailed?
>>
>> Suppose that while editing file.foo, I initiate a script
>> e.g. :so myscript.vim
>> and there is an error
>> e.g. the script looks for a non existing pattern in file.foo
>> After issuing its error message what is the expected action
>> for the general case:
>> 1. The script is immediately terminated, returning to the
>> invocation point?
>> 2. After possibly issuing an error message,
>> the script continues trying to execute with its next command.
>> In this case as if the search for the pattern had not failed?
>>
>> Are these kinds of exception rules spelled out explicitly
>> anywhere in the available documentation?
>> Not just mentioned in passing by an example!
>>
>> In my simple test case, it appears that 2. is the rule.
>> But of course I'm just seemingly poking a black box.
>
> :h except-compat
>
> Normally, a script is sourced to the end, even if errors occur. This is
> the same in all (also older) Vim versions.
>
> But if :source is executed within a :try-block, sourcing will stop on
> the first error.
> try
> so script.vim
> endtry
>
> If you want to still source to the end, you have to use :sil! to
> surpress errors:
> try
> :sil! so script.vim
> endtry
>
> What you can't have is: execute :so within a :try-block and still see
> all error messages (not only the first).
>
All very good hints and commets, thank you messieurs: Brabant, Schmidt,
and Wokula.

However none of you answered,
>> Are these kinds of exception rules spelled out explicitly
>> anywhere in the available documentation?
>> Not just mentioned in passing by an example!

>> Where are the rules for this detailed?

Or is this an impossible task, since the rules of vim
are not regular, but an ad hoc collection?
(like French grammar. :-) )

--
Rostyk

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

[Thanks] Re: Function to write correctly French quotation marks

Hi Christian and Ben,

I've spent some time these last two days to understand your suggestions
regarding my query and I must say that I had a tough time with them. But
I tried and learnt a lot. So I'm not going to continue on this thread,
as I'm using the keymap mapping solution which fits pretty well my
needs.

I just wanted to both thank you for the time, patience and great
committment that you have shown to help me solve my (little) problem. It
was (is) very appreciated.

Have a nice day,
Steve


PS: I'll probably be back here very soon as I really want to learn more
on vim. Again thanks.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: What is supposed to happen if there is an error in a vim script?

Am 31.03.2011 08:38, schrieb Rostyslaw Lewyckyj:
> IF vim recognizes an error in a script, what does it do?
> Where are the rules for this detailed?
>
> Suppose that while editing file.foo, I initiate a script
> e.g. :so myscript.vim
> and there is an error
> e.g. the script looks for a non existing pattern in file.foo
> After issuing its error message what is the expected action
> for the general case:
> 1. The script is immediately terminated, returning to the
> invocation point?
> 2. After possibly issuing an error message,
> the script continues trying to execute with its next command.
> In this case as if the search for the pattern had not failed?
>
> Are these kinds of exception rules spelled out explicitly
> anywhere in the available documentation?
> Not just mentioned in passing by an example!
>
> In my simple test case, it appears that 2. is the rule.
> But of course I'm just seemingly poking a black box.

:h except-compat

Normally, a script is sourced to the end, even if errors occur. This is
the same in all (also older) Vim versions.

But if :source is executed within a :try-block, sourcing will stop on
the first error.
try
so script.vim
endtry

If you want to still source to the end, you have to use :sil! to
surpress errors:
try
:sil! so script.vim
endtry

What you can't have is: execute :so within a :try-block and still see
all error messages (not only the first).

--
Andy

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: What is supposed to happen if there is an error in a vim script?

On Thu, March 31, 2011 9:52 am, Ben Schmidt wrote:
> Note that mappings abort on error, though. I think other commands like @
> might,
> too. Since both these can actually run scripts, one way or another, it
> somewhat
> depends in what context your script is running how errors are handled. To
> be sure
> how things will work, use :try.

True. Didn't think about mappings.

regards,
Christian

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

GVim and GTK: hide some file patterns in the file dialog boxes

Hi,

I thought I could settle this using only ".gtkrc" but it doesn't seem
to offer such a functionality.

I use Vim to develop in Python and when I open a file, the GTK dialog
box shows both .py and .pyc files. And since I sort files by reversed
last modification date, the .pyc files come first.

There are other extensions, typically compiled files (in a broad
sense), that I would like to hide.

There is a "browsefilter" but it only works on Windows and Motif.

How would you hide some file patterns from the GTK dialog boxes?

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: What is supposed to happen if there is an error in a vim script?

On 31/03/11 6:25 PM, Christian Brabandt wrote:
> On Thu, March 31, 2011 8:38 am, Rostyslaw Lewyckyj wrote:
>> IF vim recognizes an error in a script, what does it do?
>> Where are the rules for this detailed?
>>
>> Suppose that while editing file.foo, I initiate a script
>> e.g. :so myscript.vim
>> and there is an error
>> e.g. the script looks for a non existing pattern in file.foo
>> After issuing its error message what is the expected action
>> for the general case:
>> 1. The script is immediately terminated, returning to the
>> invocation point?
>> 2. After possibly issuing an error message,
>> the script continues trying to execute with its next command.
>> In this case as if the search for the pattern had not failed?
>>
>> Are these kinds of exception rules spelled out explicitly
>> anywhere in the available documentation?
>> Not just mentioned in passing by an example!
>>
>> In my simple test case, it appears that 2. is the rule.
>> But of course I'm just seemingly poking a black box.
>
> Yes, in general, rule 2 applies. But when writing your script,
> you can define otherwise, using e.g. try/catch/finally or the abort
> keyword when defining a function.

Note that mappings abort on error, though. I think other commands like @ might,
too. Since both these can actually run scripts, one way or another, it somewhat
depends in what context your script is running how errors are handled. To be sure
how things will work, use :try.

Ben.


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: What is supposed to happen if there is an error in a vim script?

On Thu, March 31, 2011 8:38 am, Rostyslaw Lewyckyj wrote:
> IF vim recognizes an error in a script, what does it do?
> Where are the rules for this detailed?
>
> Suppose that while editing file.foo, I initiate a script
> e.g. :so myscript.vim
> and there is an error
> e.g. the script looks for a non existing pattern in file.foo
> After issuing its error message what is the expected action
> for the general case:
> 1. The script is immediately terminated, returning to the
> invocation point?
> 2. After possibly issuing an error message,
> the script continues trying to execute with its next command.
> In this case as if the search for the pattern had not failed?
>
> Are these kinds of exception rules spelled out explicitly
> anywhere in the available documentation?
> Not just mentioned in passing by an example!
>
> In my simple test case, it appears that 2. is the rule.
> But of course I'm just seemingly poking a black box.

Yes, in general, rule 2 applies. But when writing your script,
you can define otherwise, using e.g. try/catch/finally or the abort
keyword when defining a function.

regards,
Christian

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Tag jumps and colon

Hi,
I use tag jumping with ctags a lot but one thing annoys me.
In C code when I have a switch case like:
switch (foo)
{
case BAR:
{
....
}
}
I cannot ctrl-leftmouse click the BAR word in order to jump to it. It
thinks that : (colon) is part of the tag name and hence cannot find it.
I am sure that there is some setting in vim for this, but I have not
been able to identify it. So how do I fix this?


thanks
Kim

--
Kim Schulz

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Wednesday, March 30, 2011

What is supposed to happen if there is an error in a vim script?

IF vim recognizes an error in a script, what does it do?
Where are the rules for this detailed?

Suppose that while editing file.foo, I initiate a script
e.g. :so myscript.vim
and there is an error
e.g. the script looks for a non existing pattern in file.foo
After issuing its error message what is the expected action
for the general case:
1. The script is immediately terminated, returning to the
invocation point?
2. After possibly issuing an error message,
the script continues trying to execute with its next command.
In this case as if the search for the pattern had not failed?

Are these kinds of exception rules spelled out explicitly
anywhere in the available documentation?
Not just mentioned in passing by an example!

In my simple test case, it appears that 2. is the rule.
But of course I'm just seemingly poking a black box.
--
Rostyk

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: If/Else for a Catch statement?

On 31/03/11 08:13, howard Schwartz wrote:
> Hi,
>
> I would like to do something like this, to process exceptions:
>
> try
> if catch /pattern/
> do this and that
> else
> do the ordinary thing
> endif
> endtry
>
> Of course this is not real code, but catches do act like an ``if'', but
> I do not know of a clean way to do an `else'. My sloppy solution was to
> define a
> variable to do it like this:
>
> try
> let s:number = 0
> catch /pattern/
> do this and that
> let s:number = 1
> finally
> if number < 1
> do the ordinary things
> endif
> endtry
>
> Any better way to do an if/else conditional, with a catch statement?

Well, nothing can be caught if there is nothing between the try and the
catch.

Otherwise you seem to have answered yourself:

try
let s:exception = 0
" do something that might trigger an exception
catch /pat1/
let s:exception = 1
" do this1-and-that1
catch /pat2/
let s:exception = 2
" do this2-and-that2
catch " any other exception
let s:exception = 999
" do this999-and-that999
finally
if !s:exception
" there was no exception
" do this0-and-that0
endif
" do any final cleanup which might be needed
" whether or not an exception was triggered
unlet s:exception
endtry


Best regards,
Tony.
--
The only really decent thing to do behind a person's back is pat it.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

If/Else for a Catch statement?

Hi,

I would like to do something like this, to process exceptions:

try
if catch /pattern/
do this and that
else
do the ordinary thing
endif
endtry

Of course this is not real code, but catches do act like an ``if'', but I do
not know of a clean way to do an `else'. My sloppy solution was to define a
variable to do it like this:

try
let s:number = 0
catch /pattern/
do this and that
let s:number = 1
finally
if number < 1
do the ordinary things
endif
endtry

Any better way to do an if/else conditional, with a catch statement?


================================================
{ PLEASE CHANGE YOUR EMAIL CONTACT LIST! }
{ If I am listed as howardb@sfo.com, change my }
{ address to howardb21@gmail.com }
================================================

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: How to git correctly...?

On 31/03/11 05:10, meino.cramer@gmx.de wrote:
> Ivan Sichmann Freitas<ivansichfreitas@gmail.com> [11-03-31 05:04]:
>>> What are the two commands needed for hq/mercurial to do the two
>>> tasks correctly?
>>
>> The detailed explanation can be found here: http://www.vim.org/mercurial.php
>>
>> In resume, you could use:
>>
>> hg clone https://vim.googlecode.com/hg/ vim
>>
>> For updating:
>>
>> hg pull
>> hg update
>>
>> Then follow the normal building instructions.
>>
>> --
>> Ivan Sichmann Freitas
>> GNU/Linux user #509059
>
>
>
> Hi Ivan!
>
> Thanks a lot ! :) :) :)
>
> Best regards
> mcc
>

I seem to have come to this thread after most had been said; but you
might still be interested in
http://vim.wikia.com/wiki/Getting_the_Vim_source_with_Mercurial
and for Unix-like OSes
http://users.skynet.be/antoine.mechelynck/vim/compunix.htm

For Windows there is also a compile.htm in the same directory as
compunix.htm but now that "Vim without Cream" distributions are
available with very little lag after each new official patch, most users
won't need to compile Vim on Windows.


Best regards,
Tony.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: call graph functionality

hi hari,

i really appreciate your effort on this front.
i guess the only reason the script is not
being used by many hardcore programmers
is it's lack of usability for huge projects.
as it is obvious that you are clearly working
on it to make it better. i would love to give
it a try, but the only reasonable way for it
to become useful is when it gets the capability
to run in background.

cheers


On Mar 30, 9:41 pm, "hari.rangara...@gmail.com"
<hari.rangara...@gmail.com> wrote:
> Version 1.21 of CCTree allows serialization of loaded cscope databases. So,
> you could run a vim process
> in the background sourcing the script which goes something like:
>
> load_my_cscope.vim:
> :CCTreeLoadDB cscope.out
> :CCTreeSaveXRefDb cctree.out
>
> $ vim -S load_my_cscope.vim
>
> Once it's done, you can load it in your current session with
> :CCTreeLoadXRefDb cctree.out
>
> The second load will take a few minutes usually. I'm currently testing a
> version that allows tracing from disk, requiring
> no load time (If you would like to try that out, let me know).
>
>
>
>
>
>
>
> On Wed, Mar 30, 2011 at 12:35 AM, sinbad <sinbad.sin...@gmail.com> wrote:
> > i was referring to CCTree Plugin in my OP. the problem with that
> > script is it can't be run
> > in background (as none of the vim scripts can), while it is building
> > the call tree,
> > vim will not be available for editing,  this is a big problem if the
> > source files are huge.
> > if vim has this capability in-built (like a pthread running in
> > background) then it will be of
> > useful. btw, i am not looking for any fancy graphical natured call
> > graphs. an ascii tree
> > like the one provided in CCTree will be enough.
>
> > On Mar 30, 12:07 pm, Sasha <sasha.h...@gmail.com> wrote:
> > > I guess you didn't like vim's cscope support (:help cscope) or the
> > > CCTree plugin (http://www.vim.org/scripts/script.php?script_id=2368).
>
> > > I assume you mean you want to generate vector/raster graphical
> > > representations of the call graph. Doing this efficiently and well
> > > realistically requires using a tool built for the purpose (e.g.
> > > codeviz, just for one example:
> >http://www.csn.ul.ie/~mel/projects/codeviz/)
>
> > > Why not find a tool which does the job as you like it, and then map
> > > keys to control that tool from vim?
>
> > > Sasha
>
> > > On Mar 30, 1:32 am, sinbad <sinbad.sin...@gmail.com> wrote:
>
> > > > hi,
>
> > > > i know many of the developers must be using vim to write
> > > > their c programs, but why there isn't an effort to add this
> > > > crucial functionality to vim. some vim scripts are available
> > > > to do exactly this, but they are not efficient and can't run
> > > > in parallel like figuring out function relationship in the
> > > > background.
>
> > > > thanks
>
> > --
> > You received this message from the "vim_use" maillist.
> > Do not top-post! Type your reply below the text you are replying to.
> > For more information, visithttp://www.vim.org/maillist.php

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: How to git correctly...?

> Nope, the following mirror by macvim's maintainer is very much alive
> and up-to-date
> https://github.com/b4winckler

Great! I didn't know that one. +1 for being hosted on github, starting to watch
it right now.

--
Ivan Sichmann Freitas
GNU/Linux user #509059

Re: How to git correctly...?

On Thu, Mar 31, 2011 at 06:34, Ivan Sichmann Freitas
<ivansichfreitas@gmail.com> wrote:
> IIRC, the git mirror of vim's repository was discontinued

Nope, the following mirror by macvim's maintainer is very much alive
and up-to-date
https://github.com/b4winckler

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: How to git correctly...?

Ivan Sichmann Freitas <ivansichfreitas@gmail.com> [11-03-31 05:04]:
> > What are the two commands needed for hq/mercurial to do the two
> > tasks correctly?
>
> The detailed explanation can be found here: http://www.vim.org/mercurial.php
>
> In resume, you could use:
>
> hg clone https://vim.googlecode.com/hg/ vim
>
> For updating:
>
> hg pull
> hg update
>
> Then follow the normal building instructions.
>
> --
> Ivan Sichmann Freitas
> GNU/Linux user #509059

Hi Ivan!

Thanks a lot ! :) :) :)

Best regards
mcc

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: How to git correctly...?

> What are the two commands needed for hq/mercurial to do the two
> tasks correctly?

The detailed explanation can be found here: http://www.vim.org/mercurial.php

In resume, you could use:

hg clone https://vim.googlecode.com/hg/ vim

For updating:

hg pull
hg update

Then follow the normal building instructions.

--
Ivan Sichmann Freitas
GNU/Linux user #509059

Re: How to git correctly...?

Ivan Sichmann Freitas <ivansichfreitas@gmail.com> [11-03-31 04:40]:
> On Thu, Mar 31, 2011 at 04:32:01AM +0200, meino.cramer@gmx.de wrote:
> >
> > Hi,
> >
> > I want to check out the git repository for vim and I want
> > to update it from time to time.
> >
> > I did this before but it seems, that I doing something wrong,
> > since vim did not compile anymore...
> >
> > What are the two commands needed to perform both of the above
> > tasks correctly?
> >
>
> IIRC, the git mirror of vim's repository was discontinued (was not even
> official). Anyway, cloning the mercurial repo and building from there works.
>
> --
> Ivan Sichmann Freitas
> GNU/Linux user #509059

Hi Ivan!

Thanks for your reply !:)

What are the two commands needed for hq/mercurial to do the two
tasks correctly?

Best regards
mcc

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: How to git correctly...?

On Thu, Mar 31, 2011 at 04:32:01AM +0200, meino.cramer@gmx.de wrote:
>
> Hi,
>
> I want to check out the git repository for vim and I want
> to update it from time to time.
>
> I did this before but it seems, that I doing something wrong,
> since vim did not compile anymore...
>
> What are the two commands needed to perform both of the above
> tasks correctly?
>

IIRC, the git mirror of vim's repository was discontinued (was not even
official). Anyway, cloning the mercurial repo and building from there works.

--
Ivan Sichmann Freitas
GNU/Linux user #509059

How to git correctly...?

Hi,

I want to check out the git repository for vim and I want
to update it from time to time.

I did this before but it seems, that I doing something wrong,
since vim did not compile anymore...

What are the two commands needed to perform both of the above
tasks correctly?

Best regards,
mcc

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: problem with Key mapping of Ctrl - End.

On 31/03/11 02:45, shuda Li wrote:
> Hi, all,
>
> I try to map the Ctrl - End to move the cursor to the end of file:
>
> map<C-End> :$<RC>
>
> However the line has no effect at all.
> I checked
>
> :map<C-End>
>
> and it returns<C-End> mapped to :$<RC>
>
> I'm wondering anyone has any clues about what causes the problem.
>
> Cheers!
>

Maybe your terminal or keyboard driver doesn't pass the Ctrl-End code as
something that Vim can recognise?

In Insert mode, and with 'showcmd' on, try hitting Ctrl-V (or Ctrl-Q if
your Vim uses Ctrl-V to paste) followed by Ctrl-End. You'll see one of
the following:

1) Nothing (the ^V remains at bottom right)
-- Meaning: the Ctrl-End keystroke is not transmitted to Vim at all.

2) (in gvim) <End>
-- Meaning: the Ctrl-End keystroke is transmitted to gvim as if it were
plain <End>

3) (in console Vim) some garbage-looking characters
-- Hit <Enter>, then Ctrl-V (or Ctrl-Q if...) followed by just <End>
-- If you see the *exact same* garbage-looking characters, then Vim
cannot tell <End> and <C-End> apart because it gets the same byte codes
for both.

(in my Console Vim I see
^[[1;5F
for Ctrl-End and
^[0F
for plain <End>).

4) Something else
-- Maybe you can determine the meaning yourself, possibly with the help of
:help terminal-options
:set termcap

Best regards,
Tony.
--
How wonderful opera would be if there were no singers.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: problem with Key mapping of Ctrl - End.

On 2011-03-30, Tim Chase wrote:
> On 03/30/2011 07:45 PM, shuda Li wrote:
> >I try to map the Ctrl - End to move the cursor to the end of file:
> >
> >map<C-End> :$<RC>
> >
> >However the line has no effect at all.
> >I checked
> >
> >:map<C-End>
> >
> >and it returns<C-End> mapped to :$<RC>
>
> Depends on what your terminal is sending. I presume this is
> (non-g)vim rather than gvim.
>
> If it's available through the terminal, the next thing to try
> would be to find out what control+end sends. To do that, type
> ":map " followed by control-V followed by control-end and post
> what it inserts on your command-line. For me in an rxvt
> terminal, it shows
>
> :map ^[[8^
>
> (where the "^[" is a literal escape).

You might also try opening a new line in a buffer and while in
insert mode, typing Ctrl-K followed by Ctrl-End. That will show you
Vim's code for that key. For me, using GNOME Terminal, inserting
Ctrl-K Ctrl-End shows

<End>

which indicates that Vim is not seeing the Ctrl modifier. That is
confirmed by Tim's Ctrl-V Ctrl-End suggestion: both End and
Ctrl-End insert

^[0F

where ^[ is Vim's symbol for the escape character, 0x1b.

Regards,
Gary

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: problem with Key mapping of Ctrl - End.

On 03/30/2011 07:45 PM, shuda Li wrote:
> I try to map the Ctrl - End to move the cursor to the end of file:
>
> map<C-End> :$<RC>
>
> However the line has no effect at all.
> I checked
>
> :map<C-End>
>
> and it returns<C-End> mapped to :$<RC>

Depends on what your terminal is sending. I presume this is
(non-g)vim rather than gvim.

If it's available through the terminal, the next thing to try
would be to find out what control+end sends. To do that, type
":map " followed by control-V followed by control-end and post
what it inserts on your command-line. For me in an rxvt
terminal, it shows

:map ^[[8^

(where the "^[" is a literal escape).

-tim

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

problem with Key mapping of Ctrl - End.

Hi, all,

I try to map the Ctrl - End to move the cursor to the end of file:

map <C-End> :$<RC>

However the line has no effect at all.
I checked

:map <C-End>

and it returns <C-End> mapped to :$<RC>

I'm wondering anyone has any clues about what causes the problem.

Cheers!

--
Shuda Li
--------------------------------
PhD  Candidate
Computer Vision Group
Room 1.15
Merchant Venturers Building
Woodland Road
the University of Bristol
Bristol BS8 1UB
United Kingdom
---------------------------------
Email:  csxsl@bristol.ac.uk
            csxsl@compsci.bristol.ac.uk
web:    http://www.cs.bris.ac.uk/~csxsl/
Office:    +44 (0)117 954 5629
Mobile : +44 (0)786 973 5073
Fax:       +44 (0)117 954 5208
---------------------------------

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Way to clear line without removing the line?

2011/3/31 Ben Schmidt
>>>
>> D is quicker ;)
>
> Depends on your keyboard and skills with the shift key. ;-)

Returning to original question, to clear whole line, cc<ESC> doesn't
need any skill with shift key in almost all keyboards and I dare to
say is more kick than 0D. Specially if you have CapsLock and Esc keys
switched.


--
Joan Miquel Torres__________________________________
Linux Registered User #164872
http://www.mallorcaweb.net/joanmiquel
BULMA: http://bulma.net http://breu.bulma.net/?l2301

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Way to clear line without removing the line?

On 30/03/11 9:30 PM, Karol Samborski wrote:
> 2011/3/30 eNG1Ne<communicator.ngn@gmail.com>:
>> Or d$ (delete from curpos to end of line) in edit mode
>>
> D is quicker ;)

Depends on your keyboard and skills with the shift key. ;-)

Ben.


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: call graph functionality



On Wed, Mar 30, 2011 at 1:07 PM, Ben Fritz <fritzophrenic@gmail.com> wrote:


On Mar 30, 11:41 am, "hari.rangara...@gmail.com"
<hari.rangara...@gmail.com> wrote:
> Version 1.21 of CCTree allows serialization of loaded cscope databases. So,
> you could run a vim process
> in the background sourcing the script which goes something like:
>
> load_my_cscope.vim:
> :CCTreeLoadDB cscope.out
> :CCTreeSaveXRefDb cctree.out
>
> $ vim -S load_my_cscope.vim
>
> Once it's done, you can load it in your current session with
> :CCTreeLoadXRefDb cctree.out
>
> The second load will take a few minutes usually. I'm currently testing a
> version that allows tracing from disk, requiring
> no load time (If you would like to try that out, let me know).
>
>
>

Wow! Does the initial generation/load take more time than the
secondary load (I hope it does)?


I didn't quite get the tone of the "Wow!". But, yes, it does take a bit of time during the first load to parse through cscope database and build a cross-reference index. Note that its written in pure native Vimscript with no external tools or interpreters. Once serialized, subsequent loads will be extremely fast.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: call graph functionality

On Mar 30, 11:41 am, "hari.rangara...@gmail.com"
<hari.rangara...@gmail.com> wrote:
> Version 1.21 of CCTree allows serialization of loaded cscope databases. So,
> you could run a vim process
> in the background sourcing the script which goes something like:
>
> load_my_cscope.vim:
> :CCTreeLoadDB cscope.out
> :CCTreeSaveXRefDb cctree.out
>
> $ vim -S load_my_cscope.vim
>
> Once it's done, you can load it in your current session with
> :CCTreeLoadXRefDb cctree.out
>
> The second load will take a few minutes usually. I'm currently testing a
> version that allows tracing from disk, requiring
> no load time (If you would like to try that out, let me know).
>
>
>

Wow! Does the initial generation/load take more time than the
secondary load (I hope it does)?

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Ctrl-W f when file doesn't exist?

Is there a setting that controls whether Ctrl-W f opens a file that
doesn't exist? I frequently find myself wanting to open a new file that
way.

It wasn't too hard to come up with a mapping:

:nmap <C-w>f :exe ":e ".fnameescape(expand("<cfile>"))<CR>

But I was just wondering whether that was unnecessary or whether there
was an easy way to have my cake and eat it too (where C-w f would both
open a non-existent file, and also search &path).

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: call graph functionality

Version 1.21 of CCTree allows serialization of loaded cscope databases. So, you could run a vim process
in the background sourcing the script which goes something like:

load_my_cscope.vim:
:CCTreeLoadDB cscope.out
:CCTreeSaveXRefDb cctree.out

$ vim -S load_my_cscope.vim

Once it's done, you can load it in your current session with
:CCTreeLoadXRefDb cctree.out

The second load will take a few minutes usually. I'm currently testing a version that allows tracing from disk, requiring
no load time (If you would like to try that out, let me know).




On Wed, Mar 30, 2011 at 12:35 AM, sinbad <sinbad.sinbad@gmail.com> wrote:
i was referring to CCTree Plugin in my OP. the problem with that
script is it can't be run
in background (as none of the vim scripts can), while it is building
the call tree,
vim will not be available for editing,  this is a big problem if the
source files are huge.
if vim has this capability in-built (like a pthread running in
background) then it will be of
useful. btw, i am not looking for any fancy graphical natured call
graphs. an ascii tree
like the one provided in CCTree will be enough.

On Mar 30, 12:07 pm, Sasha <sasha.h...@gmail.com> wrote:
> I guess you didn't like vim's cscope support (:help cscope) or the
> CCTree plugin (http://www.vim.org/scripts/script.php?script_id=2368).
>
> I assume you mean you want to generate vector/raster graphical
> representations of the call graph. Doing this efficiently and well
> realistically requires using a tool built for the purpose (e.g.
> codeviz, just for one example:http://www.csn.ul.ie/~mel/projects/codeviz/)
>
> Why not find a tool which does the job as you like it, and then map
> keys to control that tool from vim?
>
> Sasha
>
> On Mar 30, 1:32 am, sinbad <sinbad.sin...@gmail.com> wrote:
>
>
>
>
>
>
>
> > hi,
>
> > i know many of the developers must be using vim to write
> > their c programs, but why there isn't an effort to add this
> > crucial functionality to vim. some vim scripts are available
> > to do exactly this, but they are not efficient and can't run
> > in parallel like figuring out function relationship in the
> > background.
>
> > thanks

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: call graph functionality

On Mar 30, 2:35 am, sinbad <sinbad.sin...@gmail.com> wrote:
> i was referring to CCTree Plugin in my OP. the problem with that
> script is it can't be run
> in background (as none of the vim scripts can)

Not quite true. There are ways to do things in the background by using
the shell or an integrated scripting language like Python. Most
plugins don't use them, though. See the following:

http://vim.wikia.com/wiki/Execute_external_programs_asynchronously_under_Windows
https://github.com/MarcWeber/vim-addon-background-cmd

> while it is building
> the call tree,
> vim will not be available for editing,  this is a big problem if the
> source files are huge.

Yes, I have same problem with CScope. I haven't gotten around to
making my setup commands asynchronous, but I intend to do
so...sometime.

> if vim has this capability in-built (like a pthread running in
> background) then it will be of
> useful. btw, i am not looking for any fancy graphical natured call
> graphs. an ascii tree
> like the one provided in CCTree will be enough.
>

I don't use CCTree, if it's possible to load a pre-generated tree from
a file rather than generating it every time you open Vim, you could
create a command which would launch another Vim in the background,
generate this file, exit Vim, and call back into the current Vim
telling it to load the file. This could use the same techniques
discussed in the tip mentioned above.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: enhanced asciidoc editing with exuberant ctags and taglist.vim

> Can you provide an example of an asciidoc file?

Sure, here's one: http://www.methods.co.nz/asciidoc/asciidoc.txt

Here's the user guide: http://www.methods.co.nz/asciidoc/userguide.html

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Hyperlinks with dashes not working

On Mar 30, 8:07 am, Tony Mechelynck <antoine.mechely...@gmail.com>
wrote:
>
> Well, at the end of the main help file (help.txt) I see the following:
>
>   vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl:
>
> which might be what you want. Notice that unlike yours, it changes the
> 'iskeyword' option setting to include almost everything from 0x21 to
> 0x7E (the dash is 0x2D). As is said under :help 'iskeyword':
>
> >    For a help file it is set to all non-blank printable characters except
> >    '*', '"' and '|' (so that CTRL-] on a command finds the help for that
> >    command).
>

Weird, I would expect the 'iskeyword' option to be set in $VIMRUNTIME/
ftplugin/help.vim

Is there a good reason this isn't done?

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Source code to HTML

On Mar 30, 5:01 am, Grigory Sarnitskiy <sargrig...@ya.ru> wrote:
> Hello, I'm trying to produce highlighted html from console.
>
> After a bit of googling I came across this solution:
>
> cat MyFile.input | vim - +TOhtml '+w out.html' '+qall!'
>
> However, resulting html is not highlighted, but in Vim and Cream highlighting works.
>
> I've never used vim before, but it is the only editor supporting syntax highlighting for the language I need (maybe there is something for emacs, but not sure).

When Vim reads from stdin, it has no way of knowing what file type you
are giving it. Vim's filetype detection mostly depends on file
extension, although some file types are determined from file content
*at the time of reading in a file*. Since Vim is reading from stdin
and not a file, it cannot even detect the file type in this way.

If for some reason you MUST use a pipe, you'll need to set the file
type manually. Something like:

cat MyFile.input | vim - '+set ft=ruby' +TOhtml '+w out.html' '+qall!'

However, even better would be to allow Vim's filetype detection to
work by itself, simply by reading the file:

vim MyFile.input +TOhtml '+w out.html' '+qall!'

Both of these methods assume that you have a .vimrc which turns on
some basic options. Since you say you've never used Vim before, this
may not be the case. Create a file in ~/.vimrc with the following
contents:

set nocompatible
filetype indent plugin on
syntax on

There may be a system-wide .vimrc which automatically does this for
you, since you say Vim and Cream both have working syntax
highlighting. Nevertheless, you may also be interested in some of the
options to TOhtml. You don't specify your version of Vim, but prior to
version 7.3, the TOhtml command defaults to using some very non-
standard markup. You can improve this by adding the following to your
~/.vimrc file:

let g:html_use_css = 1

This is not needed if you Vim version is 7.3 or greater.

There are plenty of other options which you can enable in the same way
which may be of interest, including:

* g:html_number_lines (turns on line numbering in the generated html,
on by default if you actually use Vim and have line numbers on inside
Vim)
* g:html_dynamic_folds (generates javascript/css allowing a user to
open/close folded text in the generated output, especially useful if
you turn on syntax-based code folding)
* g:use_xhtml (deprecated, replaced by g:html_use_xhtml in Vim 7.3)
(uses xhtml instead of html, if you prefer)

The following are only available in Vim 7.3 or greater:
* g:html_ignore_conceal (if your filetype's syntax highlighting
conceals or replaces certain text, e.g. maybe it replaces &mdash; with
a real em-dash character)
* g:html_use_xhtml (see above, replaces g:use_xhtml)

The following were introduced in patches to Vim 7.3, you may not have
these unless you have the very latest Vim:
* g:html_expand_tabs (useful if you intend to copy-paste from the
generated html, and you want to keep real tabs in your document)

If you have any problems with the file encoding, first try upgrading
your Vim, because this has been greatly improved in recent versions.
If you still have problems, recent updates to TOhtml provide the
following options:
* g:html_use_encoding (technically present for quite some time but it
didn't actually change the document encoding until a recent patch,
just the meta tag)
* g:html_encoding_override (introduced in a patch to Vim 7.3)
* g:html_charset_override (introduced in a patch to Vim 7.3)

Consult the help within Vim for details on any of these. Do this by
launching Vim and typing:

:help :TOhtml

then pressing Enter.

In addition to all this, if you want not just syntax highlighting of a
single file, but also a syntax-highlighted "diff view" between two
different versions of the file, Vim 7.3 and higher supports this
in :TOhtml as well. Modify your command-line as follows:

vimdiff file1 file2 +TOhtml '+w diff_out.html' '+qall!'

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Source code to HTML

* Grigory Sarnitskiy <sargrigory@ya.ru> [110330 12:01]:
> Hello, I'm trying to produce highlighted html from console.
>
> cat MyFile.input | vim - +TOhtml '+w out.html' '+qall!'
>
> However, resulting html is not highlighted, but in Vim and Cream highlighting works.
My guess is that when vim reads your source code via stdin,
vim -
the filetype is not recognized.

> I've never used vim before, but it is the only editor supporting syntax highlighting for the language I need (maybe there is something for emacs, but not sure).
Try open the file directly, this works for me:

vim MyFile.input +TOhtml '+w out.html' '+qall!'


Regards,
mo

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Hyperlinks with dashes not working

On 30/03/11 10:13, Marco wrote:
> On 2011-03-30 Tony Mechelynck<antoine.mechelynck@gmail.com> wrote:
>
>>>> Dashes work in the hyperlinks for the Vim help, so if
>>>> I were you I'd look at the modelines (see ":help
>>>> modeline") for several of these Vim helpfiles (their
>>>> modelines are not all identical) and copy a typical
>>>> one at the end of your custom helpfiles.
>>>
>>> I copied working modelines into my help files, but the problem persists.
>>>
>>> Marco
>>>
>>
>> Well, what does Vim answer when you type
>>
>> :verbose set ft? isk?
>> :filetype
>>
>> (starting from Normal mode of course) in one of those
>> helpfiles ?
>
> Normal file:
> filetype=
> iskeyword=@,48-57,_,192-255
> filetype detection:ON plugin:ON indent:ON
>
> My help file:
> filetype=help
> Last set from modeline
> iskeyword=@,48-57,_,192-255
> filetype detection:ON plugin:ON indent:ON
>
> I used the following modeline
> vim:tw=78:ts=8:ft=help:norl:
>
>
> Marco
>
>

Well, at the end of the main help file (help.txt) I see the following:

vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl:

which might be what you want. Notice that unlike yours, it changes the
'iskeyword' option setting to include almost everything from 0x21 to
0x7E (the dash is 0x2D). As is said under :help 'iskeyword':

> For a help file it is set to all non-blank printable characters except
> '*', '"' and '|' (so that CTRL-] on a command finds the help for that
> command).


Best regards,
Tony.
--
You will be surprised by a loud noise.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Hyperlinks with dashes not working

On 2011-03-30 "Benjamin R. Haskell" <vim@benizi.com> wrote:

> > I suspect a misconfiguration somewhere in my system.
> > How to get links with dashes working?
>
> Do hyperlinks *without* dashes work in the same file? I got the same
> errors before I did the following two things:

Yes, they work.

> 1. Put the help file in a subdirectory of your
> 'runtimepath' appended with 'doc'
>
> So, if :se rtp? returns:
>
> runtimepath=~/.vim,/usr/share/vim/vim73,~/.vim/after

It does.

> In order to be found as a *help* tag, the file would
> need to be in one of these directories:
>
> ~/.vim/doc

There it is.

> 2. Build the help tags index for that file using the
> :helpt[ags] command.
>
> If your file is in ~/.vim/doc, call it as:
>
> :helpt ~/.vim/doc

Done.

> Doing both of those things seemed to fix the problem for
> this sample file:
>
> ==> ~/.vim/doc/helptest.txt <==
> Dest for *asdf-fdsa*
> Link to |asdf-fdsa|

E426: tag not found: asdf

>
> Dest for *abcd*
> Link to |abcd|

Works

>
> Dest for *efgh*
> Link to |efgh-XXXXXXXX|
> Link to |XXXXXXXX-efgh|

Jumps to *efgh* if cursor is located on the efgh part,
error otherwise.

>
> The last two links show that Vim will fall back to splitting on hyphens
> if the whole isn't found. Only works for the efgh portion of the
> link... I guess the thought is that a plugin might forget to update a
> link: e.g. |mypluginname-oldoption| still finds:
> *mypluginname* even if there's no destination for the entire tag.
> ===============================
>
> :e ~/.vim/doc/helptest.txt
> :se ft=help bt=help
^^^^^^^

Ahhh! The buftype was missing. Thank you. This solved the
problem. I didn't know that a buftype exists, I always
worked with filetype.

Thanks.


Marco

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Hyperlinks with dashes not working

On Wed, 30 Mar 2011, Marco wrote:

> I have some troubles creating help files with dashes in the
> hyperlinks. When a dash appears in a hyperlink, vim consideres the
> parts to be independent words. Dashes in the help files shipped with
> vim are no problem, this happens just to my own ones.
>
> Example:
>
> |my-helptopic|
>
> *my-helptopic*
>
> In the link above I either get: »E426: tag not found: helptopic«
> or »E426: tag not found: my«
>
> I suspect a misconfiguration somewhere in my system. How to get links
> with dashes working?

Do hyperlinks *without* dashes work in the same file? I got the same
errors before I did the following two things:

1. Put the help file in a subdirectory of your 'runtimepath' appended
with 'doc'

So, if :se rtp? returns:

runtimepath=~/.vim,/usr/share/vim/vim73,~/.vim/after

In order to be found as a *help* tag, the file would need to be in one
of these directories:

~/.vim/doc
/usr/share/vim/vim73/doc
~/.vim/after/doc

(The first one is the obvious recommendation.)


2. Build the help tags index for that file using the :helpt[ags]
command.

If your file is in ~/.vim/doc, call it as:

:helpt ~/.vim/doc


Doing both of those things seemed to fix the problem for this sample
file:

==> ~/.vim/doc/helptest.txt <==
Dest for *asdf-fdsa*
Link to |asdf-fdsa|

Dest for *abcd*
Link to |abcd|

Dest for *efgh*
Link to |efgh-XXXXXXXX|
Link to |XXXXXXXX-efgh|

The last two links show that Vim will fall back to splitting on hyphens
if the whole isn't found. Only works for the efgh portion of the
link... I guess the thought is that a plugin might forget to update a
link: e.g. |mypluginname-oldoption| still finds:
*mypluginname* even if there's no destination for the entire tag.
===============================

:e ~/.vim/doc/helptest.txt
:se ft=help bt=help
:helpt ~/.vim/doc
" after that, the links work

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Way to clear line without removing the line?

2011/3/30 eNG1Ne <communicator.ngn@gmail.com>:
> Or d$ (delete from curpos to end of line) in edit mode
>
D is quicker ;)

Regards,
Karol Samborski

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Source code to HTML

Hello, I'm trying to produce highlighted html from console.

After a bit of googling I came across this solution:

cat MyFile.input | vim - +TOhtml '+w out.html' '+qall!'

However, resulting html is not highlighted, but in Vim and Cream highlighting works.

I've never used vim before, but it is the only editor supporting syntax highlighting for the language I need (maybe there is something for emacs, but not sure).

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Hyperlinks with dashes not working

On 2011-03-30 Tony Mechelynck <antoine.mechelynck@gmail.com> wrote:

> >> Dashes work in the hyperlinks for the Vim help, so if
> >> I were you I'd look at the modelines (see ":help
> >> modeline") for several of these Vim helpfiles (their
> >> modelines are not all identical) and copy a typical
> >> one at the end of your custom helpfiles.
> >
> > I copied working modelines into my help files, but the problem persists.
> >
> > Marco
> >
>
> Well, what does Vim answer when you type
>
> :verbose set ft? isk?
> :filetype
>
> (starting from Normal mode of course) in one of those
> helpfiles ?

Normal file:
filetype=
iskeyword=@,48-57,_,192-255
filetype detection:ON plugin:ON indent:ON

My help file:
filetype=help
Last set from modeline
iskeyword=@,48-57,_,192-255
filetype detection:ON plugin:ON indent:ON

I used the following modeline
vim:tw=78:ts=8:ft=help:norl:


Marco


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Hyperlinks with dashes not working

On 30/03/11 09:20, Marco wrote:
> On 2011-03-30 Tony Mechelynck<antoine.mechelynck@gmail.com> wrote:
>
>> On 30/03/11 08:29, Marco wrote:
>>> I have some troubles creating help files with dashes in
>>> the hyperlinks. When a dash appears in a hyperlink, vim
>>> consideres the parts to be independent words. Dashes in
>>> the help files shipped with vim are no problem, this
>>> happens just to my own ones.
>>>
>>> Example:
>>>
>>> |my-helptopic|
>>>
>>> *my-helptopic*
>>>
>>> In the link above I either get: »E426: tag not found:
>>> helptopic« or »E426: tag not found: my«
>>>
>>> I suspect a misconfiguration somewhere in my system. How
>>> to get links with dashes working?
>>>
>>>
>>> Marco
>>>
>>>
>>
>> Dashes work in the hyperlinks for the Vim help, so if I were you I'd
>> look at the modelines (see ":help modeline") for several of these Vim
>> helpfiles (their modelines are not all identical) and copy a typical one
>> at the end of your custom helpfiles.
>
> I copied working modelines into my help files, but the problem persists.
>
> Marco
>
>

Well, what does Vim answer when you type

:verbose set ft? isk?
:filetype

(starting from Normal mode of course) in one of those helpfiles ?


Best regards,
Tony.
--
Oh Dad! We're ALL Devo!

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: call graph functionality

i was referring to CCTree Plugin in my OP. the problem with that
script is it can't be run
in background (as none of the vim scripts can), while it is building
the call tree,
vim will not be available for editing, this is a big problem if the
source files are huge.
if vim has this capability in-built (like a pthread running in
background) then it will be of
useful. btw, i am not looking for any fancy graphical natured call
graphs. an ascii tree
like the one provided in CCTree will be enough.

On Mar 30, 12:07 pm, Sasha <sasha.h...@gmail.com> wrote:
> I guess you didn't like vim's cscope support (:help cscope) or the
> CCTree plugin (http://www.vim.org/scripts/script.php?script_id=2368).
>
> I assume you mean you want to generate vector/raster graphical
> representations of the call graph. Doing this efficiently and well
> realistically requires using a tool built for the purpose (e.g.
> codeviz, just for one example:http://www.csn.ul.ie/~mel/projects/codeviz/)
>
> Why not find a tool which does the job as you like it, and then map
> keys to control that tool from vim?
>
> Sasha
>
> On Mar 30, 1:32 am, sinbad <sinbad.sin...@gmail.com> wrote:
>
>
>
>
>
>
>
> > hi,
>
> > i know many of the developers must be using vim to write
> > their c programs, but why there isn't an effort to add this
> > crucial functionality to vim. some vim scripts are available
> > to do exactly this, but they are not efficient and can't run
> > in parallel like figuring out function relationship in the
> > background.
>
> > thanks

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Hyperlinks with dashes not working

On 2011-03-30 Tony Mechelynck <antoine.mechelynck@gmail.com> wrote:

> On 30/03/11 08:29, Marco wrote:
> > I have some troubles creating help files with dashes in
> > the hyperlinks. When a dash appears in a hyperlink, vim
> > consideres the parts to be independent words. Dashes in
> > the help files shipped with vim are no problem, this
> > happens just to my own ones.
> >
> > Example:
> >
> > |my-helptopic|
> >
> > *my-helptopic*
> >
> > In the link above I either get: »E426: tag not found:
> > helptopic« or »E426: tag not found: my«
> >
> > I suspect a misconfiguration somewhere in my system. How
> > to get links with dashes working?
> >
> >
> > Marco
> >
> >
>
> Dashes work in the hyperlinks for the Vim help, so if I were you I'd
> look at the modelines (see ":help modeline") for several of these Vim
> helpfiles (their modelines are not all identical) and copy a typical one
> at the end of your custom helpfiles.

I copied working modelines into my help files, but the problem persists.

Marco


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: call graph functionality

I guess you didn't like vim's cscope support (:help cscope) or the
CCTree plugin (http://www.vim.org/scripts/script.php?script_id=2368).

I assume you mean you want to generate vector/raster graphical
representations of the call graph. Doing this efficiently and well
realistically requires using a tool built for the purpose (e.g.
codeviz, just for one example: http://www.csn.ul.ie/~mel/projects/codeviz/)

Why not find a tool which does the job as you like it, and then map
keys to control that tool from vim?

Sasha

On Mar 30, 1:32 am, sinbad <sinbad.sin...@gmail.com> wrote:
> hi,
>
> i know many of the developers must be using vim to write
> their c programs, but why there isn't an effort to add this
> crucial functionality to vim. some vim scripts are available
> to do exactly this, but they are not efficient and can't run
> in parallel like figuring out function relationship in the
> background.
>
> thanks

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: call graph functionality

I guess you didn't like vim's cscope support (:help cscope) or the
CCTree plugin
(http://www.vim.org/scripts/script.php?script_id=2368).

I assume you mean you want to generate vector/raster graphical
representations
of the call graph. Doing this efficiently and well really requires
using
a tool built for the purpose (e.g. codeviz, just for one example other
than cscope:
http://www.csn.ul.ie/~mel/projects/codeviz/).

Why not find a tool which does the job exactly as you prefer, and then
map keys to
control that tool from vim?

Sasha

On Mar 30, 1:32 am, sinbad <sinbad.sin...@gmail.com> wrote:
> hi,
>
> i know many of the developers must be using vim to write
> their c programs, but why there isn't an effort to add this
> crucial functionality to vim. some vim scripts are available
> to do exactly this, but they are not efficient and can't run
> in parallel like figuring out function relationship in the
> background.
>
> thanks

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Tuesday, March 29, 2011

Re: Way to clear line without removing the line?

Or d$ (delete from curpos to end of line) in edit mode

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Hyperlinks with dashes not working

On 30/03/11 08:29, Marco wrote:
> I have some troubles creating help files with dashes in
> the hyperlinks. When a dash appears in a hyperlink, vim
> consideres the parts to be independent words. Dashes in
> the help files shipped with vim are no problem, this
> happens just to my own ones.
>
> Example:
>
> |my-helptopic|
>
> *my-helptopic*
>
> In the link above I either get: »E426: tag not found:
> helptopic« or »E426: tag not found: my«
>
> I suspect a misconfiguration somewhere in my system. How
> to get links with dashes working?
>
>
> Marco
>
>

Dashes work in the hyperlinks for the Vim help, so if I were you I'd
look at the modelines (see ":help modeline") for several of these Vim
helpfiles (their modelines are not all identical) and copy a typical one
at the end of your custom helpfiles.

Best regards,
Tony.
--
God made the integers; all else is the work of Man.
-- Kronecker

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: call graph functionality

On Mar 30, 1:32 am, sinbad <sinbad.sin...@gmail.com> wrote:
> hi,
>
> i know many of the developers must be using vim to write
> their c programs, but why there isn't an effort to add this
> crucial functionality to vim. some vim scripts are available
> to do exactly this, but they are not efficient and can't run
> in parallel like figuring out function relationship in the
> background.
>
> thanks

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

call graph functionality

hi,

i know many of the developers must be using vim to write
their c programs, but why there isn't an effort to add this
crucial functionality to vim. some vim scripts are available
to do exactly this, but they are not efficient and can't run
in parallel like figuring out function relationship in the
background.

thanks

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Hyperlinks with dashes not working

I have some troubles creating help files with dashes in
the hyperlinks. When a dash appears in a hyperlink, vim
consideres the parts to be independent words. Dashes in
the help files shipped with vim are no problem, this
happens just to my own ones.

Example:

|my-helptopic|

*my-helptopic*

In the link above I either get: »E426: tag not found:
helptopic« or »E426: tag not found: my«

I suspect a misconfiguration somewhere in my system. How
to get links with dashes working?


Marco


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: enhanced asciidoc editing with exuberant ctags and taglist.vim

On Mar 25, 6:22 am, Adam Monsen <hair...@gmail.com> wrote:
> Has anyone done work on enhancing editing of asciidoc text (perhaps
> using exuberant ctags and taglist.vim)? I thought it might be nice to,
> for instance, have taglist provide an outline of an asciidoc file.

The command VxOccurRoutines from the package vimuiex supports asciidoc
and reStructuredText, but only in SVN. If you want to try it, you can
download the script http://www.vim.org/scripts/script.php?script_id=2606
and get the updated files from
http://vimuiex.svn.sourceforge.net/viewvc/vimuiex/trunk/runtime/vimuiex/autoload/vimuiex/.
The files you need to update are vxoccur.vim and vxoccur_defaults.vim.

A version of the vimuiex popup list that doesn't require Python is
being prepared. It will probably be ready in a month, then I will
upload the new version.

Marko

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: Function to write correctly French quotation marks

Hi Steve!

On Di, 29 Mär 2011, Steve wrote:

> Hi,
>
> A swedish chap suggested offlist a very good idea, which is to do a
> keymap mapping:
>
> Create a file ~/.vim/keymap/guilem.vim in which put:
>
> loadkeymap
> << «<Char-0xa0>
> >> <Char-0xa0>»
>
> And then
>
> :setl kmp=guilem
>
> This a good solution for several reasons, first of all it's rather
> simple :), then it can be extended to so-called double punctuation (<;>,
> <:>, <?> and <!>) which in French must be preceded by a <nbsp>. So all I
> have to do is add
>
> : <Char-0xa0>:
> ; <Char-0xa0>;
>
> etc... to have French writing automatically corrected. Very convenient.
> All is left to me is to remember to load this keymap, which should be
> fine, but if it could be done automatically when writing in French, it
> would be terrific. I guess I could set this by default (I write more
> often in French than in english) and disable it when writing in English
> (with something like :setl nokmp, right?). Detecting a language must not
> be easy I guess.

Interesting. I have never used keymaps before, but it looks promising.

regards,
Christian
--
Ein Pessimist ist ein Optimist, der nachgedacht hat.
-- Dan Bennet

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: enhanced asciidoc editing with exuberant ctags and taglist.vim

On Mar 29, 2011, at 10:27 AM, Gerhard Siegesmund <jerriman@gmail.com> wrote:

> Hello
>
>> Has anyone done work on enhancing editing of asciidoc text (perhaps
>> using exuberant ctags and taglist.vim)? I thought it might be nice to,
>> for instance, have taglist provide an outline of an asciidoc file.
>>
>
Can you provide an example of an asciidoc file?

Dave

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Re: enhanced asciidoc editing with exuberant ctags and taglist.vim

Hello

> Has anyone done work on enhancing editing of asciidoc text (perhaps
> using exuberant ctags and taglist.vim)? I thought it might be nice to,
> for instance, have taglist provide an outline of an asciidoc file.
>

Maybe the plugin voom could be enhanced to also support asciidoc.

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

--
cu
--== Jerri ==--
Homepage: http://www.jerri.de/ ICQ: 54160208
Public PGP Key: http://www.jerri.de/jerris_public_key.asc

Re: Why Ruby is not supported on Vim7.3 (needed for commandT)

On 28 March 2011 13:28, Benjamin R. Haskell <vim@benizi.com> wrote:
> On Mon, 28 Mar 2011, wei gao wrote:
>
>> I'm using GVim from vim.org which doesn't support ruby. BTW, is this Cream
>> version the official one? Is it stable?
>
> No, it's not the official one.  Yes, it's stable.

Another unofficial one here (with full Perl, Python2, Python3, Ruby,
Tcl, and Lua support):

http://wyw.dcweb.cn/#download

It is just the executables for quick replacement.

--
Wu Yongwei
URL: http://wyw.dcweb.cn/

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php