16

Have you tried the edit command? :edit b.pl Edit: Not sure if you edited in the last question, or I just missed it the first time. But the only reason you wouldn't be able to use relative paths on :split or :tabnew is if your current working directory isn't the same as the file you're currently editing. So I think what you're looking for is :set ...


13

:cd %:h Explain: :cd change directory Vim command % - full path to current file %:h - full path to current file without filename itself. See :help expand and :help :cd for more information


13

Use :e %:h<filename>, or specifically for your question :e %:hb.pl. Individually these tokens mean :e edit, but you could use :tabnew or :split etc % the current file path :h 'head', which in this usage is the directory of the currently open file <filename> the relative path of the file you want to open You can ...


11

What you're looking for is :Vexplore. From your question, it sounds like you started off knowing only about :Sexplore and understandably thought that that was the basic command for bringing up the vim file explorer (which is called netrw). However, the basic command is just :Explore, and :SExplore is actually just a variant of that. The basic :Explore ...


9

I'm assuming you are using netrw here, as it's the default action when you do vim . or vim some/directory/. You can create a file/directory from netrw with the following commands: d : create a directory, you will be prompted to input the directory name % : create a file, same workflow Have a look at :h netrw for more informations.


8

See :h :cd and :h :lcd. :cd changes the current directory for all the windows while :lcd changes the current directory for the current window. You can change the current directory to the directory containing the current file with: :cd %:p:h And you can use set autochdir in your .vimrc to change the current working directory whenever you open a file, ...


7

I set the following two options to ensure that Vim's current working directory is always the same as the current buffer's. set autochdir " Changes the cwd to the directory of the current " buffer whenever you switch buffers. set browsedir=current " Make the file browser always open the current ...


7

Yes, vim has a :cd command, which either prints the current directory or changes the current directory. In the help is this - note the last lines: :cd[!] {path} Change the current directory to {path}. If {path} is relative, it is searched for in the directories listed in |'cdpath'|. ...


7

I am grateful to @statox for useful hints, but as I don't wont to change current dir each time I come to following: map <F6> :let $VIM_DIR=expand('%:p:h')<CR>:terminal<CR>cd $VIM_DIR<CR>


5

This appears to be an issue that was introduced in a patch that was picked up by Ubuntu 16.04 and fixed in another patch. Here's a link to the bug report. It was fixed in patch 1716 but, unfortunately, 16.04 shipped with patches only up to 1689. Hopefully there'll be an update soon. Otherwise it's compile the latest version from source, I'm afraid.


5

It is possible by setting the netrw configuration variable g:netrw_keepdir to 0 (default is 1). To make it permanent, add in the .vimrc file this line: let g:netrw_keepdir=0


5

I just installed nautilus, and it seems the current working directory is always set to the directory nautilus was started from (ie. Vim inherits nautilus' working directory). This is a problem in nautilus (IMHO), and not Vim. When nautilus starts a new process (Vim) it can set the working directory, but doesn't. If I check /proc/22656/cwd it's set to /home/...


4

Try the autodir setting in vimrc. set autochdir


4

This was a bug, that was fixed in 7.4.096. (You didn't specify exact version, so I assume, you are using plain 7.4 version and I used to have the same problem when cding into a UNC path)


4

If you want to get the directory of the first file in :argv (the filename arguments when vim was opened): let g:session_default_name = fnamemodify(argv()[0], ':p:h'). This will fail if vim was opened with no arguments. To fallback on getcwd() where there were no arguments: " Returns the directory of the first file in `argv` or `cwd` if it's empty function ...


4

First of all wherever you open vim, you have access to the whole filesystem from within vim. If you open vim without parameters or if you open a new buffer inside of vim with :new you can then save it to the drive with :w \path\to\file Then to access to those files you have a lot of different options. For example : netrw which is the built in file Explorer ...


3

You could use set autochdir in the vimrc to make the working directory that of the current file. Apparently you need to be careful with this option and plugins.


3

I assume by "Highlight current line" that you're referring to the set cursorline option? Sounds like a job for autocmd's I'd do something like: autocmd BufEnter * call UnhighlightLine() function! UnhighlightLine() if (expand('%:p') =~ '/Work/my_rails_project_1\|/Work/my_rails_project_2') set nocursorline else set cursorline endif ...


3

Totally a different angle, but it works without having to install any plugins ... When I want to create or rename a directory from a running Vim session, I'll simply type :! followed by the appropriate shell command, doing something like the following: For Linux :! mkdir newdir to create a directory :! mv newdir renamed_dir to rename a directory For ...


3

Fugitive If your project is under git's control then you use Fugitive.vim. :echo fugitive#repo().tree() To edit a file relative to the git root you an use :Gedit and a /: :Gedit /tasks/mytask.js For more help see: :h fugitive :h :Gedit Projectionist If you are using Projectionist.vim then you can get the inner most directory by doing the following: :...


3

2 ways of doing that: On your terminal, move to your project directory then execute vim. Manually specify the working directory into vim using :cd command (You can check the current working directory with :pwd). Extra CtrlP If you're using ag with ctrlp, you can create a .agignore file into your working directory, and specify there what ctrlp should ...


3

From the documention it would seem that it should be using your ~/Sites/project directory. (See :h :NERDTree) :NERDTree [<start-directory> | <bookmark>] *:NERDTree* Opens a fresh NERD tree. The root of the tree depends on the argument given. There are 3 cases: If no argument is given, the current directory ...


3

As of vim8, mkview by default stores current directory for every buffer. You can find lcd <path> lines inside your views. To disable this: set viewoptions-=curdir


3

You can access the working directory of another window with the function getcwd(). So although this isn't the most convenient or robust solution, if your root project (with the global working directory) is in the first, leftmost tab page, you could use the command: :execute 'cd' getcwd(1, 1) This will remove the local current directory and set the global ...


3

As of vim 8.0.1489, one may use getcwd(-1) to retrieve the global directory. Thus, the following will work to restore a window to the global directory and cause it to forget its local directory (as explained in the documentation): if haslocaldir() execute 'cd' getcwd(-1) endif This feature was available in neovim before it made it to vim. Prior to ...


3

Try the following: set wildignore=*/node_modules/* I just played a little with wildignore, so I don't know if it works in all cases. E.g. if you do a :vimgrep /pattern/ node_modules/** It will find nothing, as all files below node_modules are ignored. See :help wildignore. Update: The option wildignore is a comma-separated list of pattern. To ignore ...


2

I solved this problem myself by using Haroogan vim. When I cd to h:\ in Haroogan vim it works, and it also successfully runs my vimrc files there. I guess this was either something strange about my work's network drive and/or a bug in vim that will eventually be resolved. Still, if you have this problem, I would try Haroogan vim.


2

I think the ReadPost events aren't applicable since the documentation describes them as related to the :read command. You could try the Enter events, either BufEnter or BufWinEnter. For example: autocmd BufWinEnter *.tex lchdir %:p:h


2

Use :set autochdir command to change the current directory. It will set the working directory as specific to the opened file.


2

Here is what I did in the end. Thanks to GitHub function! NERDTreeToggleInCurDir() " If NERDTree is open in the current buffer if (exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) != -1) exe ":NERDTreeClose" else if (expand("%:t") != '') exe ":NERDTreeFind" else exe ":NERDTreeToggle" endif endif ...


Only top voted, non community-wiki answers of a minimum length are eligible