Wikia

Vim Tips Wiki

Replace the file name extension

Talk0
1,613pages on
this wiki
Revision as of 05:32, July 13, 2012 by JohnBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Tip 469 Printable Monobook Previous Next

created 2003 · complexity basic · author Vincent NAUDOT · version 5.7


Here is a map allowing you to press "\'" in insert mode. It saves the current tex file, then compiles it.

map! \' <Esc>:w<CR>:! latex %<CR>i

You may wonder how to open the associated dvi file. Simply replace % with %<.dvi to give:

map! <F4> <Esc>:! xdvi %<.dvi <CR>i
"Or (if using K environment):
map! <F4> <Esc>:! kdvi %<.dvi <CR>

The same thing applies for any other extension. The following will open the associated ps file with gv.

map! <F5> <Esc>:! gv %<.ps <CR>i

CommentsEdit

This is deprecated, the preferred form is %:r

And in fact there's a whole bunch more things you can do than just remove the extension - you can remove the directory/path, keep just the extension, etc etc by using different ':' modifiers.

:help filename-modifers


There is the vim-latex-project: http://vim-latex.sourceforge.net/

If you install that in your ~/.vim you will have a lot of improvments over the map. \ll compiles your .tex-file, \lv shows you the .dvi. `d give you \delta, and `D gives you \Delta. There is so much, just check it out!


Around Wikia's network

Random Wiki