What's the meaning of 'inoremap' in vimrc

后端 未结 3 1252
清歌不尽
清歌不尽 2020-12-24 13:14

There is a line below in vimrc example file

inoremap Ctrl-u Ctrl-G u Ctrl-u

What\'s the meaning of inoremap and w

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-24 13:31

    The vim :help inoremap is very poetic about this:

    :ino[remap] {lhs} {rhs}         mapmode-i             :ino :inoremap
    :ln[oremap] {lhs} {rhs}         mapmode-l             :ln  :lnoremap
    :cno[remap] {lhs} {rhs}         mapmode-c             :cno :cnoremap
                        Map the key sequence {lhs} to {rhs} for the modes
                        where the map command applies.  Disallow mapping of
                        {rhs}, to avoid nested and recursive mappings.  Often
                        used to redefine a command.  {not in Vi}
    

    Thus it makes some insert-mode mappings for ^U that show the filename (^G, undo the most recent change (u), and scrolls the buffer upwards by half a screen (^U).

    I have no idea why someone would want this specific sequence of commands, except to demonstrate the inoremap feature -- the ^U at the refers to the meaning the command had when the definition was created, rather than calling back into the redefined ^U mapping.

提交回复
热议问题