When opening a file from dolphin gvim doesn't take over the correct path info

Bug #293215 reported by benzimmer
4
Affects Status Importance Assigned to Milestone
vim (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: vim-gnome

Scenario:

This is happening on Intrepid (8.10) amd64

vim-gnome package version: 1:7.1.314-3ubuntu3
dolphin package version: 4:4.1.2-0ubuntu4

- Mapped the file-association of .tex files to gvim
- Opening a .tex file from dolphin (or konqueror)
- Trying to use some features from vim-latexsuite (e.g.: :call Tex_ViewLatex() for viewing the compiled document in an external viewer)
-> commands have no effect, because gvim thinks its still located at the standard path (/home/user) which can be confirmed by running '!ls' from the vim-command-line.

Problem doesn't exist when I run gvim from the command-line. '!ls' then shows the path where the edited document is located and gvim/latex-suite works as expected.

Don't know if its really a gvim issue or more a dolphin/konqueror/kde issue...

Revision history for this message
Nicolas Bonnefon (nickbnf) wrote :

hmm... seems like expected behaviour to me. gvim's 'current directory' is the directory where it is run from, not the directory of the file edited. e.g. if you run "gvim ~/myfolder/myfile.tex" from your home dir, vim's current dir will be your home, not ~/myfolder.
From within gvim, you can use :pwd to display the current directory, and :cd ~/myfolder to change it.

A possible solution to your problem is too add this to your .vimrc:
autocmd BufRead * cd %:p:h
It will automatically change the current directory to the one of the file read when you open a file (it can be a bit irritating because it does it for all files, including helpfiles...) so you can use that if you prefer:
autocmd BufRead *.tex cd %:p:h

Revision history for this message
Radek (radek-42) wrote :

Hi,

I do not know what is going on, but it surly sounds strange. I can confirm, that \lv command works if gvim is started from the terminal either by
gvim test.tex
or
gvim Documents/test.tex

Therefore it does not appear to be a problem with working directory.

On the other hand if one starts editing *.tex file from file manager (thunar in my case) it does not work. I also tried to set up starting directory for thunar to be ~/Documents where my *.tex (and *.pdf) files are and it still does not work.

It gets kind of annoying after a while :-)

Ideas?

PS. I also notice that from time to time \lv switches into "visual" mode rather that executing viewing command. Any idea why?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.