Fix cursor position in insert and visual mode