LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-20-2006, 03:52 PM   #1
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Rep: Reputation: 30
Start Vim in alternate directory


Can't seem to find this in the man page... how do you start vim with it's current directory in a directory other than the current directory. In other words, the relative path once it's started is my home directory. What do I need to do to make it start with that directory ~/otherdir, for example (so I'd type ":e foo" instead of ":e otherdir/foo")?
 
Old 01-20-2006, 05:54 PM   #2
bigjohn
Senior Member
 
Registered: Jun 2002
Location: UK .
Distribution: *buntu (usually Kubuntu)
Posts: 2,692
Blog Entries: 9

Rep: Reputation: 45
I'm completely confused as to what you're trying to do ! Vi/Vim is an editor does it do other things ???

As I understand it, just vi /whatever directory you want/whatever file you want - If you manage to start it i.e. you have user permissions to run it, you still may not have the user permissions to edit/alter the file, but if you have then surely it just starts - from a terminal ???

If theres some way of starting it so that it opens a terminal and then goes to the directory you want ????

Perhaps you could clarify exactly what it is that you're trying to do a little more.

regards

John
 
Old 01-20-2006, 06:14 PM   #3
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Original Poster
Rep: Reputation: 30
Sorry about that, probably typed that post in too much of a rush. I'm taking a programming course and will be using gvim (just looks a little nicer than normal vim-in-a-terminal). If I run just "gvim", I'll get a vim session with vim's "current directory" as my home directory. I'd like to be able to use vim to directly work on (i.e. edit, switch between, compile, run) files that are a few directories deeper. At this point, I'd have to do things like ":e src/spring06/project2/Foo.java" and "java src/spring06/project2/Foo", where I'd like to avoid typing the repeated part of the path. It's just a very small optimization, one that I could get by starting gvim and then doing ":cd src/spring06/project2", but there has to be a way to do that on startup, via a command-line option or something in the .vimrc. Thinking about it a little more I suppose I could do a shell script with something like "cd src/spring06/project2; gvim", but I'd like to do it the way it's supposed to be done.

Thanks again.

--EDIT--
One more clarification... the reason I can't just do "gvim src/spring06/project2/Foo.java" is I'll be editing and moving around between multiple files in that directory, and starting gvim that way (as far as I know) will still leave vim's current directory as my home directory.

Last edited by jrdioko; 01-20-2006 at 06:16 PM.
 
Old 01-20-2006, 06:41 PM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
If you're in your home directory and you want to open gvim based in ~/src/spring06/project2, try this:

Code:
gvim -c 'cd ~/src/spring06/project2'
 
Old 01-20-2006, 07:53 PM   #5
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Original Poster
Rep: Reputation: 30
That'll do, thanks!
 
Old 01-20-2006, 10:03 PM   #6
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
No problem
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
setting directory permissions at start redrobin77 Fedora 1 11-05-2005 01:26 PM
wher is my vimrc file and the .vim directory slac 10.0 rkrishna Slackware 3 04-11-2005 03:50 AM
Xterm does not start in root directory mystique98ls Linux - Newbie 2 12-14-2004 05:45 PM
start directory atheist Linux - Software 3 06-05-2004 05:01 PM
start vim when vi is typed PlatinumRik Linux - Software 7 03-15-2004 04:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration