VIM Select Entire Line

Capital V selects the current line in one key stroke; two, if you include the "shift" in shift+v.


While this might be more keystrokes.

If you are already in visual mode you can use o to go to the other end of the visual selection.

So you can type

v0o$

To select the whole line. Take a look at :h visual-change


However from the comments it seems you just want to copy the whole line.

Which would just be yy


V would be direct answer. However, I rarely need to do this because "selecting the current line" is generally part of a larger task. Example of such tasks includes copying the line and deleting the line. There's generally a better way to accomplish the task as a whole. The following are some of the tasks I can think of:

  • copy the line: yy
  • delete the line: dd
  • indent the line: >> or <<
  • select the current paragraph: vap or vip
  • delete from the current line to the end of the file 0dG
  • highlight the current line to see where my cursor is: use :set cursorline in .vimrc file

One case in which I do use V is to select multiple lines that are not a paragraph or some other text object. In this case, there's a tip that might be useful for you: once in the selection mode, you can use o to jump the cursor between the start and the end of the selection.

Tags:

Vim