Fix cursor position in insert and visual modes