Re: How to identify filetype during plugin initialization?
- Hi Luc,
On Wed, 24 Sep 2003 01:17:40 +0200
Luc Hermitte <hermitte@...> wrote:
> Why don't you try to play with the code of one of the "commentifiers"Actually, I did download and analyzed EnhancedCommentify before
> like EnhancedCommentify for instance.
starting, and I did base my work on it. Details below...
> When you the call the function that will toggle the comment on a line,Right, that did the trick. The reason why it was not working was because
> test the value of &ft. That's all.
> if &ft == 'cpp' | echo "I'm editing a C++ file"
> elseif &ft == 'vim' | echo "I'm editing a VimL file"
I was not using it inside of my commentify function, but instead as part
of the plugin initialization code (i.e. code outside any function). I
moved my filetype identification code inside the function, and it
"automagically" works =) I guess that at the time the script is loaded,
&ft simply doesn't exist.
This goes to prove I still have a lot to understand about scope,
buffers, initialization routines etc. =/ (BTW: I did read vim excellent
docs about plugins and startup procedures, I probably overlooked this
> Do check plugins like EnhancedCommentify.I did that, I just didn't make it clear on my original msg. Sorry.
Thank you very much for the tip, now I got it fully working =)
Andre Oliveira da Costa