Changing extension of current filename (%) in vimrc

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Changing extension of current filename (%) in vimrc

Narayanan S. Iyer
Hi,

I am editing a file called *filename.tex*.

When I press F9, I would like this to be compiled, for which I use
*map  <F9> :!latex % ^M*

Now, when I press <F10>, I would like to run another program *yap*, with
the input *filename.dvi* (Note the change of extension)

Could anyone please let me know how I can map this in .vimrc?

Regards,
iyerns
Reply | Threaded
Open this post in threaded view
|

Re: Changing extension of current filename (%) in vimrc

Aditya Mahajan
<--- On May 28, Narayanan S. Iyer wrote --->
>
> When I press F9, I would like this to be compiled, for which I use
> *map  <F9> :!latex % ^M*
>
> Now, when I press <F10>, I would like to run another program *yap*, with
> the input *filename.dvi* (Note the change of extension)
>
> Could anyone please let me know how I can map this in .vimrc?

Rather than creating your own mapping, try out latex-suite
http://vim-latex.sourceforge.net/ which has a lot of features for
editing and compiling latex files in vim. You can easily change the
default compile and view mappings to latex-suite to <F9> and <F10>

HTH,
Aditya
Reply | Threaded
Open this post in threaded view
|

Re: Changing extension of current filename (%) in vimrc

Gary Johnson
In reply to this post by Narayanan S. Iyer
On 2005-05-28, "Narayanan S. Iyer" <[hidden email]> wrote:

> Hi,
>
> I am editing a file called *filename.tex*.
>
> When I press F9, I would like this to be compiled, for which I use
> *map  <F9> :!latex % ^M*
>
> Now, when I press <F10>, I would like to run another program *yap*, with
> the input *filename.dvi* (Note the change of extension)
>
> Could anyone please let me know how I can map this in .vimrc?

This is explained here:

    :help filename-modifiers

To change the current file's extension to .dvi, you would use this:

    %:r.dvi

so you're mapping would be this:

    map <F9> :!yap %:r.dvi<CR>

HTH,
Gary
Reply | Threaded
Open this post in threaded view
|

Re: Changing extension of current filename (%) in vimrc

Gary Johnson
On 2005-05-28, Gary Johnson <[hidden email]> wrote:
[...]

> so you're mapping would be this:

Oops.

s/you're/your/

Gary

--
Gary Johnson                 | Agilent Technologies
[hidden email]     | Wireless Division
                             | Spokane, Washington, USA