how to set default working directory in vim and cygwin?

0

2

My system is gvim 7.4+xp+cygwin.

Everytime i open vim or cygwin,input pwd

pwd in cygwin to get :
/cygdrive/c/Documents and Settings/sy

I want to set the default directory /cygdrive/c/workspace
pwd in gvim to get :
c:/Documents and Settings/sy

I want to set the default directory c:/workspace
How can i make the setup in vim and cygwin?

1.i created a file named .bash_profile ,add two lines cd /cygdrive/c/workspace
echo "hallo world "

no effect at all.

2.i add cd /cygdrive/c/workspace in the file profile,the wrong output is : -bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: $'\r': command not found
': not a valid identifier
-bash: $'\r': command not found
-bash: /etc/profile: line 104: syntax error near unexpected token $'\r''
'bash: /etc/profile: line 104:
profile_d ()
-bash-4.1$

it_is_a_literature

Posted 2013-12-31T06:54:13.783

Reputation: 373

I do not understand what you are trying to do. Do you want the Cygwin terminal to start in the /cygdrive/c/workspace directory? You refer to both vim and gvim. Are you using the Cygwin or the Windows versions of vim and gvim? – garyjohn – 2013-12-31T07:12:07.567

Answers

0

For Cygwin, put

cd /cygdrive/c/workspace

in ~/.bash_profile.

Or, maybe what you want to do is to make /cygdrive/c/workspace your home directory; by default that's where a Cygwin shell will start. To do that, edit the entry for your user in /etc/passwd. Then restart the Cygwin shell.

For gvim, create a shortcut to start gvim, right-click on it, go to Properties..., then enter C:/workspace in the "Start in" field.

Andrew Schulman

Posted 2013-12-31T06:54:13.783

Reputation: 2 696

there is no .bash_profile in cygwin,how can i do? – it_is_a_literature – 2013-12-31T11:08:24.600

If you don't have one yet, create it. It goes in your home directory (which is what ~ means). – Andrew Schulman – 2013-12-31T11:16:07.483

I added a description of how to change your home directory - maybe better. – Andrew Schulman – 2013-12-31T11:18:04.210

i created a file named .bash_profile and add two lines cd /cygdrive/c/workspace and echo "hallo world ", no effect at all. – it_is_a_literature – 2013-12-31T11:38:37.883

If .bash_profile is in your home directory and bash is your shell, it will run it when it starts. – Andrew Schulman – 2013-12-31T13:49:01.953