[vimmode] refactor the mapping code