The autocmd template to match the file name and part of the path

I am trying to start auto-cmd by opening a new file with a start, including test/with a file name ending in Test.java. Reading in :h autocmd-patternsI cannot understand if only limited templates can be used as a file template in auto-cmd, or if I'm just doing something wrong with my template. The following steps are for matching any file ending in.java

autocmd! BufNewFile *.java
 \ "command implemented !

Now I'm trying to match new files with a path containing /test/, and with a file name ending in Test.java, through the following and its derivatives

autocmd! BufNewFile */test/*Test.java
 \ "command implemented !

How to enable autorun for all files that have part of the path in the folder test/and file name ending in Test.java. For example, it should work at execution

$ vim code/algos/graphs/test/KruskalTest.java
+5
2
augroup MyJavaAUGroup
  au! BufRead,BufNewFile,BufEnter *.java,*Test.java,*/test/* <<YOURCOMMANDHERE>>
augroup END
+3

**/test/*Test.java. , , : BufNewFile , .

+1

All Articles