I currently use Vim for Java development. I use maven and for a small project I typically begin by running
vim .
or vim pom.xml
from terminal at project root and
:argadd **/*.java
to add all the java files to the arguments list.
Then I edit away. It works very well, but there is some headache, like my statusline not being composed well for showing deeply nested filepaths, etc., but my question is specifically about editing a file in the same directory as the file I'm editing in the current buffer.
For example, say I am editing a Java interface src/main/java/com/fancy/restclient/Client.java
. I am happy with the interface and want to create an implementation in the same folder. I type
:spl %:p:h/ClientImpl.java
to edit ClientImpl.java
, in the same folder, in a horizontal split.
Is there a faster way to do this? I type this very slowly and it breaks my train of thought (choo choo!) Should I just suck it up and get used to it, or am I missing out on a more glorious editing experience? How would you edit a different file in the same directory as the current file?
- When I want to edit a file in the same directory which already exists I usually have it in my args list and
:spl | b Cli<Tab>
is convenient. If it exists but is not in my args list I can use:find
and friends to get at it quickly. So my question is primarily about editing new files. - I don't want to use
autochdir
because I have a compiler set up that expects the working directory to be the project root (and it also would make it more complicated to edit files in a different directory branch of the project).