-2

Every time I log in with the username debian8 and open a file (whose path is /home/debian8/Desktop/homework/test.txt) with Vim, the :pwd command returns /home/debian8

How could I make /home/debian8/Desktop/homework the current directory? So I don't have to resort to :cd /home/debian8/Desktop/homework to change it after opening the file.

Jair López
  • 650
  • 1
  • 5
  • 16
showkey
  • 482
  • 42
  • 140
  • 295

2 Answers2

1

From :help 'autochdir'

When on, Vim will change the current working directory whenever you open a file, switch buffers, delete a buffer or open/close a window. It will change to the directory containing the file which was opened or selected. Note: When this option is on some plugins may not work.

Jair López
  • 650
  • 1
  • 5
  • 16
-3
  1. Navigate to your project directory:

    $ cd Desktop/homework/
    
  2. Edit your file:

    $ vim test.txt
    
romainl
  • 186,200
  • 21
  • 280
  • 313
  • why not set autochdir in the configuration file? – showkey May 15 '16 at 14:41
  • Because it's just as useless as downvoting answers you don't understand. Why don't you learn to use your system instead of asking silly questions? – romainl May 15 '16 at 14:43
  • I have give the answer as you provide it :cd /home/debian8/Desktop/homework to change it after opening the file,you copy my answer,so it is right for me to downvote your answer.it is no relationship with asking silly question. – showkey May 15 '16 at 23:40
  • You don't deserve any help. – romainl May 16 '16 at 08:17