The Vim syntax file was updated for this in v7.4.649 (March 2015); so if you have this patch you don't need to do this.
The easiest way to fix this is probably by downloading the newer syntax/java.vim file and putting it in ~/.vim/syntax/java.vim so it will override the default $VIMRUNTIME/syntax/java.vim. You will also need to symlink html.vim ...
It can be done with a substitution with a sub-replace-expression:
:%s/\ze\(\s*\)private \w\+ \(\w\+\)/\=submatch(1).'@Column(name="'.substitute(submatch(2), '\u', '_\l&', 'g').'");'."\r"
For more help see:
First thing I notice is that you have quotes in there. When using set everything after the = symbol is set to the value.
Since errorformat has spaces and backslashes my preferred way to set it is with let and single-quoted strings, then string concatenation so I can break it up into more easily parsed lines.
let &errorformat =
\ '%*[^"]"%f"%*\D%l: ...
Thanks to David Ben Knoble's comment I was able to find relevant information and solve my problem. I did as follows and it worked for me:
In .vimrc, remove source ~/yang.vim, add :syntax on and :filetype plugin on (I added them to the top of the file). Inside vim (normal mode), type :set runtimepath?. In my case one of the directories printed was ~/.vim. ...
Yet another solution
g/^\s*private/copy. | normal! -2dwdw"_C@Column(name = "^R=substitute(@-, '\(\l\)\(\u\)', '\1_\l\2', 'g')^M")
g/^\s*private/... for all lines starting with "<spaces>private"
copy. | normal! ... make a copy of the current line then enter normal mode command
-2dwdw"_C up one line ...
If you'd accept a solution that requires a Vim plug-in (specifically for the snake case coercion), then I could recommend one that involves recording a macro to process each line.
In particular, you would have to install plug-in vim-abolish, which includes a cr operation to do case coersion, in particular crs (or equivalently cr_) for snake_case.
So you ...
I figured it out, mostly. Vim has a special version of the zero-width assertion. It doesn't recognize the standard regex ?= zero-width assertion. Thanks to Karl and user1685095 for pointing out the \ze specifier.
Actually you can use either \ze or \@= - though, as pointed out by user1685095, \ze is the more efficient of the two. \@= is a successor operation ...