In general I prefer to have annotation tags for methods, including @Test ones, on the line before the method declaration like this
@Test
public void testMyMethod() {
// Code
}
rather than
@Test public void testMyMethod() {
// Code
}
I have java specific settings in ~/.vim/ftplugins/java.vim. What can I add to java.vim such that indentation is skipped at the first line after the @Test tag? At the moment vim will, as it is supposed to according to java.vim, indent 4 characters giving
@Test
____* <-- cursor placed here
while I would prefer
@Test
* <-- Cursor placed here
I do something similar in C++, where my company’s coding style doesn’t want indents in namespace blocks. There’s an answer for that at this post, adapting it to your question would just swap the
'^\s*namespace.*'bit to your desired pattern. If it’s for all annotations, perhaps simply…Save this in your vimfiles (inside ~/vimfiles or on windows in your homedir or inside ProgramFiles\vim\vimfiles) as indent/java.vim. You may be able to simplify by removing the while/endwhile hunt for a non-blank line if you require an annotation to occur on a line exactly above the line you’re indenting (with no intervening blank lines).