intrucing new sintax highligth

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

intrucing new sintax highligth

roberto-6
Hi all,
i currently edit octave files under gvim but i am constrained to use
MATLAB highligthing pattern which is already fairly similar to Octave.
But Octave has some different keywords like "endfunction" not present in MATLAB;
can i modify MATLAB highligthing pattern to add some new keywords??

thank you very much in advance : )

--
roberto
debian sarge, kernel 2.6.8
Reply | Threaded
Open this post in threaded view
|

Re: intrucing new sintax highligth

Dominic Evans
On 15/09/05, roberto <[hidden email]> wrote:
> Hi all,
> i currently edit octave files under gvim but i am constrained to use
> MATLAB highligthing pattern which is already fairly similar to Octave.
> But Octave has some different keywords like "endfunction" not present in MATLAB;
> can i modify MATLAB highligthing pattern to add some new keywords??

Well the obvious answer to that question is yes...
...but you might find its already done for you

see here for an octave syntax highlighting script
http://www.vim.org/scripts/script.php?script_id=1241
Reply | Threaded
Open this post in threaded view
|

Re: intrucing new sintax highligth

roberto-6
On 9/15/05, Dominic Evans <[hidden email]> wrote:

> On 15/09/05, roberto <[hidden email]> wrote:
>MATLAB;
> > can i modify MATLAB highligthing pattern to add some new keywords??
>
> Well the obvious answer to that question is yes...
> ...but you might find its already done for you
>
> see here for an octave syntax highlighting script
> http://www.vim.org/scripts/script.php?script_id=1241
>
yes, but following instructions of that page ia cannot find my vim dir
and vim syntax subdirectory, where are they? should i create them?
any help appreciated : )


--
roberto
debian sarge, kernel 2.6.8
Reply | Threaded
Open this post in threaded view
|

Re: intrucing new sintax highligth

Dominic Evans
open vim and type :echo $VIMRUNTIME
that is where your vim files are stored

i see you are using unix so its probably somewhere within
/usr/local/share/vim or /usr/share/vim

On 15/09/05, roberto <[hidden email]> wrote:

> On 9/15/05, Dominic Evans <[hidden email]> wrote:
> > On 15/09/05, roberto <[hidden email]> wrote:
> >MATLAB;
> > > can i modify MATLAB highligthing pattern to add some new keywords??
> >
> > Well the obvious answer to that question is yes...
> > ...but you might find its already done for you
> >
> > see here for an octave syntax highlighting script
> > http://www.vim.org/scripts/script.php?script_id=1241
> >
> yes, but following instructions of that page ia cannot find my vim dir
> and vim syntax subdirectory, where are they? should i create them?
> any help appreciated : )
>
>
> --
> roberto
> debian sarge, kernel 2.6.8
>
Reply | Threaded
Open this post in threaded view
|

Re: introducing new sintax highligth

roberto-6
On 9/15/05, Dominic Evans <[hidden email]> wrote:
> open vim and type :echo $VIMRUNTIME
> that is where your vim files are stored
>
> i see you are using unix so its probably somewhere within
> /usr/local/share/vim or /usr/share/vim
>
ok, it seems to work correctly up to know,
so thany you very much : )
bye

--
roberto
debian sarge, kernel 2.6.8
Reply | Threaded
Open this post in threaded view
|

Re: intrucing new sintax highligth

Charles E Campbell Jr
In reply to this post by Dominic Evans
Dominic Evans wrote:

>open vim and type :echo $VIMRUNTIME
>that is where your vim files are stored
>
>i see you are using unix so its probably somewhere within
>/usr/local/share/vim or /usr/share/vim
>
>On 15/09/05, roberto <[hidden email]> wrote:
>  
>
>>On 9/15/05, Dominic Evans <[hidden email]> wrote:
>>    
>>
>>>On 15/09/05, roberto <[hidden email]> wrote:
>>>MATLAB;
>>>      
>>>
>>>>can i modify MATLAB highligthing pattern to add some new keywords??
>>>>        
>>>>
>>>Well the obvious answer to that question is yes...
>>>...but you might find its already done for you
>>>
>>>see here for an octave syntax highlighting script
>>>http://www.vim.org/scripts/script.php?script_id=1241
>>>
>>>      
>>>
>>yes, but following instructions of that page ia cannot find my vim dir
>>and vim syntax subdirectory, where are they? should i create them?
>>any help appreciated : )
>>    
>>
Its not the best thing to put new syntax files into the distribution's
directory.  That method would
result in your losing any customizations the next time you upgrade.

So, may I suggest putting the octave.vim syntax highlighting in your  
$HOME/.vim/syntax
directory.  If you don't have such a directory, mkdir it (I'm talking
Unix here as his sig implies
he's using debian).   I don't know what the suffix is that octave files
(tend to) use is; I'm guessing
its the same as matlab's .m.  If so, place the following in  a file:  
$HOME/.vim/filetype.vim
 
if exists("did_load_myfiletypes")
 finish
endif
let did_load_myfiletypes= 1
augroup filetypedetect
 au BufNewFile,BufReadPost *.m                            setf octave
augroup END

The filetype.vim file tells vim what filetypes should be associated with
which suffices.
If you have additional suffices, just add additional "au Buf..." lines
with the appropriate
suffix in the  augroup.

With this approach, you have your customizations in $HOME/.vim, which
will not be affected
by updating vim.  You can also have plugin/ , ftplugin/ , etc in your
$HOME/.vim directory.

Regards,
Chip Campbell

Reply | Threaded
Open this post in threaded view
|

Re: intrucing new sintax highligth

roberto-6
On 9/15/05, Charles E. Campbell, Jr. <[hidden email]> wrote:

> Its not the best thing to put new syntax files into the distribution's
> directory.  That method would
> result in your losing any customizations the next time you upgrade.
>
> So, may I suggest putting the octave.vim syntax highlighting in your
> $HOME/.vim/syntax
> directory.  If you don't have such a directory, mkdir it (I'm talking
> Unix here as his sig implies
> he's using debian).   I don't know what the suffix is that octave files
> (tend to) use is; I'm guessing
> its the same as matlab's .m.  If so, place the following in  a file:
> $HOME/.vim/filetype.vim
>
> if exists("did_load_myfiletypes")
>  finish
> endif
> let did_load_myfiletypes= 1
> augroup filetypedetect
>  au BufNewFile,BufReadPost *.m                            setf octave
> augroup END
>
> The filetype.vim file tells vim what filetypes should be associated with
> which suffices.
> If you have additional suffices, just add additional "au Buf..." lines
> with the appropriate
> suffix in the  augroup.
>
> With this approach, you have your customizations in $HOME/.vim, which
> will not be affected
> by updating vim.  You can also have plugin/ , ftplugin/ , etc in your
> $HOME/.vim directory.
>
> Regards,
> Chip Campbell
>
>
i'll try your way, but these "."  files of Unix-like system are
automatically loaded at booting time? how can i make my system use
them? i guess from your answer that it is enough to create them ...
is it right?


--
roberto
debian sarge, kernel 2.6.8
Reply | Threaded
Open this post in threaded view
|

Re: intrucing new sintax highligth

Charles E Campbell Jr
roberto wrote:

>i'll try your way, but these "."  files of Unix-like system are
>automatically loaded at booting time? how can i make my system use
>them? i guess from your answer that it is enough to create them ...
>is it right?
>  
>

Every time vim is invoked it will look for files to load in the
$HOME/.vim directory tree.
See :he runtimepath for more on this.

Good luck!
Chip Campbell

Reply | Threaded
Open this post in threaded view
|

Re: intrucing new sintax highligth

A.J.Mechelynck
In reply to this post by Dominic Evans
----- Original Message -----
From: "Dominic Evans" <[hidden email]>
To: <[hidden email]>
Cc: <[hidden email]>
Sent: Thursday, September 15, 2005 11:37 AM
Subject: Re: intrucing new sintax highligth


> open vim and type :echo $VIMRUNTIME
> that is where your vim files are stored
>
> i see you are using unix so its probably somewhere within
> /usr/local/share/vim or /usr/share/vim
>
DON'T change anything in or under $VIMRUNTIME because anything there may be
silently replaced the next time you upgrade. You may then suddenly find,
after an upgrade, that things that "used to work" suddenly don't work
anymore, or work differently, because months or years ealier you put your
files in a "wrong" directory. Also, the name of the $VIMRUNTIME directory is
version-dependent, so when you decide to upgrade to version 7 everything you
might previously have put in /usr/share/vim/vim63 will suddenly stop
functioning.

Use the other directory trees mentioned in 'runtimepath' and place the files
at the same relative point in the tree.

For instance, syntax files distributed with Vim are in $VIMRUNTIME/syntax/
(e.g., in usr/share/vim/vim63/syntax/ on Unix, in "C:\Program
Files\vim\vim63\syntax" on Windows)

Place your own full-fledged syntax scripts in either $VIM/vimfiles/syntax/
(system-wide: e.g. /usr/share/vim/vimfiles/syntax/ on Unix, "C:\Program
Files\vim\vimfiles\syntax" on Windows) or ~/.vim/syntax/ (user-private on
Unix: e.g. /home/roberto03/.vim/syntax/) or ~/vimfiles/syntax (user-private
on Windows: e.g. "C:\Documents and Settings\roberto03\vimfiles\syntax").

If a syntax file already exists but you want to add small changes and
customizations to it, place those in either $VIM/vimfiles/after/syntax/
~/.vim/after/syntax/ or ~/vimfiles/after/syntax/ (the |after-directory|
[q.v.] subordinate to one of the above, depending on your platform and on
whether the changes are system-wide defaults or user-specific preferences).

Similary, since "distributed" filetype-plugins are in $VIMRUNTIME/ftplugin/
you should put your own full-fledged filetype-plugins in one of
$VIM/vimfiles/ftplugin/, ~/.vim/ftplugin/ or ~/vimfiles/ftplugin/, and small
ftplugin customizations in $VIM/vimfiles/after/ftplugin/,
~/.vim/after/ftplugin/ or ~/vimfiles/ftplugin/.

Any not-yet-existent directory may be created when you need to put a file in
it. For instance, neither $VIM/vimfiles/ nor $VIM/vimfiles/syntax/ exist by
default. Let's say you want to download a syntax script and make it
available to all users on your system. Then, assuming you have write (and
file-creation) access rights to $VIM, you can do

(on Windows)
    cd "C:\Program Files\vim"
    md vimfiles
    md vimfiles\syntax

(on Unix-like systems)
    cd /usr/share/vim
    mkdir -p vimfiles/syntax

You can then, on either platform, open your browser, go to the download
page, and tell it to save the file to the "syntax" subdirectory you just
created. Or if you download the file in a compressed archive form, you may
sometimes bypass the directory-creation step and tell your archive unzipper
to create the directory to which the file is to be extracted.


Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: intrucing new sintax highligth

A.J.Mechelynck
In reply to this post by roberto-6
----- Original Message -----
From: "roberto" <[hidden email]>
Cc: <[hidden email]>
Sent: Thursday, September 15, 2005 4:26 PM
Subject: Re: intrucing new sintax highligth
[...]

> i'll try your way, but these "."  files of Unix-like system are
> automatically loaded at booting time? how can i make my system use
> them? i guess from your answer that it is enough to create them ...
> is it right?
>
>
> --
> roberto
> debian sarge, kernel 2.6.8

Yes, create those directories when you need them; and use "ls -a" or
"ls -la" etc. to see them in a directory listing (usually, files and
directories whose names start with a period are "hidden"; the -a option
reveals them).

Best regards,
Tony.