Sometimes I accidentally tell vim to edit a directory instead of a file in it
vim directory-name # what I typed
vim directory-name/blah.txt # what I meant to type
Instead of immediately giving an error message, vim will open the directory in a "file editor" mode that I personally don't like:
How can I make vim refuse to open directories instead?
One possible avenue could be by changing some settings in my .vimrc but I don't know what they would be.
Another possibility would be to create a wrapper shell alias around vim that checks with something along the lines of test -d "$1"
to see if I'm trying to open a file. However, I don't know to make this alias robust so that it can tell apart which command-line arguments are flags and which are file names.
vim
doesn't edit directories. It discovers that your argument is a directory it gives you the choice to select one of the files within that directory. You may be incompatible tovim
, so choose a different editor or help yourself with a shell function that checks if your argument is a file or not.