I am trying to make an auto-cmd triggered by opening a new file with path including test/
and with filename ending in Test.java
. Reading in :h autocmd-patterns
I can not figure out if either only limited patterns can be used as a file pattern in an auto-cmd or if I am simply doing something wrong with my pattern. The following works for matching any file ending in .java
autocmd! BufNewFile *.java
\ "command implemented !
Now I try to match new files with a path containing /test/
and with a file name ending in Test.java
through the following and derivatives of it
autocmd! BufNewFile */test/*Test.java
\ "command implemented !
How do I trigger the autocmd on all files having part of their path the test/
folder and the filename ending in Test.java
. For instance it should be triggered on doing
$ vim code/algos/graphs/test/KruskalTest.java
augroup MyJavaAUGroup
au! BufRead,BufNewFile,BufEnter *.java,*Test.java,*/test/* <<YOURCOMMANDHERE>>
augroup END
Try using the **/test/*Test.java
pattern instead. Also, ensure that
you chose the correct auto-command event: For the BufNewFile
event to be
triggered, it is necessary for the file with a given name not to exist.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With