Re: Folding between #ifdef _DEBUG and #endif

2006-10-10 Thread Kamil Kisiel

On 10/11/06, Hari Krishna Dara [EMAIL PROTECTED] wrote:


On Tue, 10 Oct 2006 at 12:14pm, Kamil Kisiel wrote:

 I've got some C++ source code that I'd like to fold away. Basically I
 want vim to have folds only between #ifdef _DEBUG and the
 corresponding #endif statement, and nowhere else. My vimfu is a bit
 weak in this respect so I'm not quite sure how I would go about doing
 this. Using foldexpr, changing the marker type? Previously I was just
 manually creating folds, but as you can imagine it gets fairly tedious
 and it would be great if I could automate it. Your help is much
 appreciated.

If the ifdefs that you want to fold are not nested, you can use my
foldutil plugin from here:

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

You would use something like:

:FoldMatching #ifdef\ _DEBUG #endif 0

The last parameter is a context, so you might like 1 better than 0
(allows you to see what you are folding). Alternatively, you can also
configure the foldtext (see plugin page or the header in the file for
information)

If you want this to be automatically done everytime you open the file,
then you need to create an autocommand e.g.,(untested):

au FileType c FoldMatching #ifdef\ _DEBUG #endif 0



Hari,

Perfect. That's exactly what I wanted, and I'm sure your script will
be useful in many other ways as well Good to find out about it, and
thanks for your work.

--
Kamil Kisiel [EMAIL PROTECTED]


Folding between #ifdef _DEBUG and #endif

2006-10-09 Thread Kamil Kisiel

I've got some C++ source code that I'd like to fold away. Basically I
want vim to have folds only between #ifdef _DEBUG and the
corresponding #endif statement, and nowhere else. My vimfu is a bit
weak in this respect so I'm not quite sure how I would go about doing
this. Using foldexpr, changing the marker type? Previously I was just
manually creating folds, but as you can imagine it gets fairly tedious
and it would be great if I could automate it. Your help is much
appreciated.

--
Kamil Kisiel [EMAIL PROTECTED]


Project specific keywords?

2006-09-20 Thread Kamil Kisiel

I would like to define keywords for syntax highlighting that are
specific to a particular project. For example, when using some
third-party API there are often frequently used keywords that I'd like
to highlight when using that API. What's the best way to set this up
with Vim, and to have the settings load automatically whenever I edit
files from that project?

--
Kamil Kisiel [EMAIL PROTECTED]


Re: foldmethod=marker confusing brace matching syntax highlighting?

2006-06-28 Thread Kamil Kisiel

On 6/27/06, A.J.Mechelynck [EMAIL PROTECTED] wrote:

Kamil Kisiel wrote:
 I've started using foldmethod=marker for folding in my C++ source
 files. Usually it works okay, but I find that several times a day the
 syntax highlighting seems to get confused and start highlighting
 braces after a particular fold in red, as if they did not have a
 matching brace. This is never actually the case, and just doing an :e
 filename again makes the problem go away for a while. It's
 nevertheless an irritating issue and it just seems to occur at random.
 Has anyone else had the same experience? Is there a fix? I'm using Vim
 7.0 on WinXP.


It might be due to how far back syntax highlighting scans the source. In
that case,

:syn sync fromstart

might cure the problem, at the possible cost of some slowdown when
opening a file for editing.

The above sets the syntax sync method for the current file only. To
apply it to all C/C++ sources opened in the future:

:au Syntax c,cpp syn sync fromstart

-- and either add the same to your vimrc or create a
~/vimfiles/after/syntax/c.vim with the line

syn sync fromstart

in it. (Create any needed files and/or folders that don't yet exist.)
(Note: C syntax is invoked by the cpp syntax script.)


Best regards,
Tony.



Thanks Tony, that appears to have done the trick.


foldmethod=marker confusing brace matching syntax highlighting?

2006-06-26 Thread Kamil Kisiel

I've started using foldmethod=marker for folding in my C++ source
files. Usually it works okay, but I find that several times a day the
syntax highlighting seems to get confused and start highlighting
braces after a particular fold in red, as if they did not have a
matching brace. This is never actually the case, and just doing an :e
filename again makes the problem go away for a while. It's
nevertheless an irritating issue and it just seems to occur at random.
Has anyone else had the same experience? Is there a fix? I'm using Vim
7.0 on WinXP.

--
Kamil Kisiel [EMAIL PROTECTED]