The following vi substitute command converts all opcodes like "LDA A" to "LDAA" %s/\s\+\w\{3}\zs\s\+\ze[AB][ \t\r\n]//