To search for lines ending with "-N" where N is a digit and replace with -0N i.e. prefix with 0 :%s/-\(.\)$/-0/g To search for lines that start with == and insert a newline followed by ``` followed by original text i.e. == /^== :%s//\r```\r&/gc /^==*$ :%s//\r```\r```/gc