> -----Original Message-----
> From: vim_use@googlegroups.com <vim_use@googlegroups.com> On Behalf Of 
> DwigtArmyOfChampions
> Sent: 17 April 2020 15:47
> To: vim_use <vim_use@googlegroups.com>
> Subject: How to get directory of current file.
> 
> I am using gVim on Windows. I open a file in C:\tmp called file1.cpp. After 
> looking around in file1.cpp I now want to open file2.cpp which is also in 
> C:\tmp. So I run the command
> 
> :e .\file2.cpp
> 
> But this doesn’t work because the “.” is C:\Windows\system32. Is there a 
> different character or function or variable I can use in command mode to 
> designate “the directory that the current file is in”?

This seems to cover what you want:

https://vim.fandom.com/wiki/Easy_edit_of_files_in_the_same_directory

Personally I have a key mapped to change to the current file's directory:

map <F7> :cd %:p:h<CR>:pwd<CR>

based on this:

https://vim.fandom.com/wiki/Set_working_directory_to_the_current_file

regards,
Geoff

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/DM6PR06MB514675DDB5BE12A391DF8968FFD90%40DM6PR06MB5146.namprd06.prod.outlook.com.

Reply via email to