Select entire line in VIM, without the new line character

后端 未结 6 1717
清歌不尽
清歌不尽 2020-12-23 16:57

Which is the shortest way to select an entire line without the new line character in VIM?

I know that SHIFT + v selects the entire line

6条回答
  •  天涯浪人
    2020-12-23 17:16

    Adding on to the answer by @glts, you can replicate the functionality of the textobj-line plugin using only vanilla vim mappings, no plugin installation required.

    To do so, add the following to your .vimrc

    vnoremap al :normal 0v$h
    omap al :normal val
    vnoremap il :normal ^vg_
    omap il :normal vil
    

    The al text object (short for 'a line') includes all characters in a line, but not the terminating newline. This includes all white space.

    The il text object (short for 'inside line') goes from the first non-blank character to the last non-blank character.

    Commands such as yil,val, and cil work as expected.

提交回复
热议问题