Replacing with $1 when $1 is empty, incorrectly inserts 'null'. It should insert nothing instead. Example: If you have the following buffer: select it.name, it.code, it.address from employees it where code = '111' Search (with regular expressions on) for: \bit(\.)*\b Replace with: emp$1 Expected results: select emp.name, emp.code, emp.address from employees emp where code = '111' Actual results: select emp.name, emp.code, emp.address from employees empnull where code = '111'