Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [working-directory]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
32 views

Wrong working directory after opening file

I currently have the problem that when I open a file, I always have a certain working directory. This is a problem, because Vim doesn't find tags files anymore. I have not set anything like this in ....
user avatar
  • 123
2 votes
1 answer
422 views

Set current working directory when opening vim

When opening neovim via nvim /path/to/directory I want the current working directory of vim to be set to the given path instead of the current path of my terminal. When opening a file instead it would ...
user avatar
  • 123
2 votes
1 answer
92 views

How to make vim recognize variables from files in the current directory or sub directories?

I have recently been working on a web project and I would like my css files to recognize the classes and ids from the html files. Is there any way to make this work? Edit: So I use coc.nvim. By ...
user avatar
0 votes
2 answers
118 views

Is there a way to quickly navigate to previously visited directories

I quickly want to switch between directories I previously visited without typing :cd and then the full pathname again and again. Is there a plugin or a way that can keep an account of the directories ...
user avatar
2 votes
1 answer
93 views

Why is current working directory in vim different from where vim was started?

vim is showing a different current working directory than the one I started vim with from the command-line. The problem goes away if I run without my .vimrc (vim -u NONE). How can I debug this to ...
user avatar
0 votes
0 answers
557 views

How to change the root directory of vim?

My vim is installed in D:\Vim\vim82, but somehow $VIM points to the directory D:\Vim\vim82\vim.exe\vim82. Therefore when I startup vim all the features that need to access folders in the root ...
user avatar
0 votes
1 answer
830 views

VimWiki linking to files in other directories with special characters

With vimwiki we can create a link to another file, [[DelmeDirectory/delme.md|File]]. I have some directories which have the form Notes_0-0-0 and aren't recognized. i.e. pressing Enter with the cursor ...
user avatar
  • 121
1 vote
1 answer
49 views

Is there a way to revert :lcd to the "global" path?

For most my projects I prefer my directory to be at a particular project root. However for some (mostly vimwiki) it's easier to have vim change the folder to the file location. This is easily done ...
user avatar
  • 259
1 vote
1 answer
109 views

switch current directory between a base directory and current file directory

Goal: To achieve filename/path completion relative to current file directory using omni completion CTRL-X CTRL-F. I open all my files contained in a base directory such that :pwd in some_file outputs ...
user avatar
1 vote
1 answer
174 views

Vundle keeps installing plugins to C:\Users\<user name> despite being told not to in .vimrc

I am using Vim on Windows. My installation directory is C:\Program Files\Vim\vim82. As I am trying to use Vundle, I installed it in .\plugin\Vundle.vim. Then, I added these to .vimrc: set ...
user avatar
2 votes
2 answers
4k views

How to use FZF to search directories and open new file in directory

Here's what I'd like to do, and I'm open to using any tool (not just fzf): I want to be able to open a new file quickly (with a horizontal split :sp) in a specific directory that I find using fzf. ...
user avatar
3 votes
1 answer
8k views

How to do :Sex but with a vertical split?

When viewing a file /tmp/vim_split_demo/test.txt, the parent directory can be opened in a horizontal split screen using the command :Sex, as shown in these screenshots: What command gives same ...
user avatar
2 votes
1 answer
127 views

How to have getcwd() give path with ~ in place of home folder?

I have the following (simplified) statusline config in my vimrc: set laststatus=2 set statusline= set statusline+=%{getcwd()} When I'm somewhere in my home directory on macOS, my statusline looks ...
user avatar
  • 566
3 votes
2 answers
848 views

How to handle multiple directories in vim?

I always have at least two directories in my projects: One with information about the projects: info.txt, log.txt One with code And every project has a name. How to group and jump efficiently ...
user avatar
  • 141
3 votes
1 answer
2k views

Exclude folder when searching files in working directory

I'm working in a react project and opened vim from the root folder. When I'm using :vimgrep /pattern/ ** I just can search everywhere, but I want to search everywhere except the 'node_modules' ...
user avatar
  • 145
1 vote
0 answers
21 views

`:bro w` initially opens wrong directory in 8.1.1

I just upgraded Vim to 8.1.1, and the behavior of :bro w seems changed: it occasionally (!?) does not open the pwd for browsing. (I checked :pwd.) This in on Win 10. Does something other than the ...
user avatar
  • 111
0 votes
1 answer
477 views

How to tell command-t to ignore a specific directory

I have a very large number of files under a specific directory. If I start vim from the wrong place, command-t tries to index the whole thing, which results in vim hanging for a long time before ...
user avatar
  • 3,399
6 votes
3 answers
601 views

How do you go back to your to global current directory after inheriting an lcd

I frequently have one root project open which I've :cd'd to. I also have other tabs with :lcd's set. This is great and works really nicely, but occasionally I end up looking at something in the main ...
user avatar
  • 1,121
0 votes
0 answers
69 views

Difference between 1 CTRL-G and :pwd, quotation marks?

The commands 1 CTRL-G and :pwd return related but different results: 1 CTRL-G "~/dev/src/tiff.c" 170 lines --15%-- :pwd /home/user/src Of course, CTRL-G returns the file, not the working ...
user avatar
  • 1,825
8 votes
2 answers
7k views

How to run internal vim terminal at current file's dir?

I edit file /home/me/projects/myproj/src/util.c And want to start terminal at /home/me/projects/myproj/src. Vim version > 8 so I can run :terminal but it always starts at folder in which I've opened ...
user avatar
  • 633
2 votes
2 answers
1k views

Working directory different than current file directory?

I saw something strange happen today. I was in directory /some/path/ and opened a file with vim file.html. I then did :pwd in vim and it gave me /some/other/path. What could cause this to happen? ...
user avatar
0 votes
2 answers
499 views

chdir doesn't work

I'm in the browsing directory mode how can I change the current directory to that one I'm browsing? At least manually. But ":chdir ." doesn't work Moreover, in the config file I have "set autochdir" ...
user avatar
  • 103
1 vote
1 answer
3k views

VimScript - How do you get file/directory vim was called on from the command line?

I am writing a little hack for vim session that will save and load sessions more conveniently - I am aiming for more project-style sessions. When you are in directory my-proj and call vim, it should ...
user avatar
2 votes
1 answer
1k views

Do not change current directory

I want to have fixed current directory equals to the directory where vim was opened. Note I am using tabs and splits, so I want to have the same current directory in all tabs and splits. How can I do ...
user avatar
  • 21
1 vote
1 answer
242 views

How can I set the working directory for only the job_start() process?

I would like to set the working directory for the process started with job_start(). The only way I know how to do this is to change Vim's current working directory before calling job_start(), and ...
user avatar
7 votes
2 answers
12k views

opening another file with path relative to current directory

I want to open another file in the same directory or any file with its path relative to the current directory in command line. My path is /home/sibich/ /home/sibich> vim a.pl In vim, I want ...
user avatar
  • 3,012
1 vote
2 answers
36 views

Highlight current line, but not for files inside certain dirs

I'd like to be able to highlight the current line the cursor is at, but not for files from certain directories. That's because I noticed the rendering becomes slow if I highlight the lines within a ...
user avatar
  • 111
10 votes
2 answers
3k views

Edit a directory inside Vim

Is it possible to edit a directory inside Vim? (Some commands are working for directories). I want to know what kind of operations can be done in a directory inside Vim. Vim can open the directories ...
user avatar
  • 3,012
5 votes
2 answers
813 views

autochdir working with :sp but not :e?

I'm on Ubuntu 16.04 (x86_64) and vim 7.4. In my config file, I have: set autochdir And this was working for as long as I remember. Just after upgrading to Ubuntu 16.04, I see the following behavior (...
user avatar
  • 549
1 vote
2 answers
291 views

After changing lcd get parent directory of original file

Is is possible to get the original working directory of vim after changing the local working directory? Let's say I open vim with parent directory: ~/projects/myproject and then I open a file and ...
user avatar
  • 111
4 votes
1 answer
656 views

CtrlP should never index particular directories

My projects are in: /home/user/projectA /home/user/projectB However, at times I hit CtrlP and I haven't opened a file in a particular project, so my working directory is /home/user. CtrlP starts ...
user avatar
-4 votes
4 answers
3k views

How to change the directory to save a file

Currently all I have to do is type vim file_name and it will make that file in the current directory (usually user because that is where the command line start at if you don't use the cd command). It ...
user avatar
7 votes
1 answer
4k views

change working directory to current opened file [duplicate]

Sometimes I use Command-T to browse files. When I find the file I needed, I would like to switch the current working directory to the opened file's directory. How can I do this?
user avatar
  • 527
1 vote
2 answers
704 views

Execute current file outside of working directory

I know I can execute the current file, lets say a bash file, with :! bash %. But what can I do if I want to execute the current file in a different directory (such as the location of the current file) ...
user avatar
  • 113
9 votes
5 answers
15k views

How to set up NERDTree to CD to current folder when opening it for the first time via :NERDTreeFind

Given: $ cd ~/Sites/project project $ vim :NERDTreeFind I would like to see NERDTree opening with ~/Sites/project as a root folder. Instead I see ~/Sites with project folder selected. So I have to ...
user avatar
  • 2,212
5 votes
3 answers
2k views

Can't change directory to network drive

Our company has recently changed to networked home directories. This includes setting enviroment variables. This has created the odd situation that gvim thinks my home directory is : :echo $HOME H:\...
user avatar
6 votes
3 answers
1k views

Switching to the local directory after loading a file?

When running gvim by double clicking with a file in a graphical file manager, like nautilus, the vim instance is called with a strange current directory (seems root sometime, but I am not sure). This ...
user avatar
  • 728
8 votes
3 answers
2k views

Make :edit {file} use current directory during :Explore

I often use :Ex or :Sex to explore the filesystem from an opened file directory, or just invoke vim passing a directory to start exploring the filesystem and then opening a file. In any case, while ...
user avatar
  • 1,667