Answer: y^
Explanation
vim is a modal editor. That means it has specific modes for doing specific things. Most common three modes are:
- Normal Mode : Enter all normal editor commands (see
:h Normal-mode
)
- Insert Mode : Insert characters (see
:h Insert-mode
- Visual Mode : Highlight a text area to perform a normal editor comman on (see
:h Visual-mode
But there are many other modes also. For more info, see :h intro.txt
In normal mode, you can perform editing tasks, for example, yanking (a.k.a copying) text. You can do that by two methods:
Normal mode : You need to perform :h Operator-pending-mode
to yank the portion of the text you want to. Vim has many text objects (see :h motion.txt
). You can go in operator-pending mode by issuing a command, in this case, yank (y) and then specify the text object to perform the command (yank) on with suitable text objects.
If you want to yank from the start of the line til the character under the cursor, I'd do y^
Visual mode : You go into visual mode with v and highlight the portion of the text you want to perform the yank command on, and then issue the command. I'd do hv^y
$ vimtutor
. Otherwise you're gonna keep getting in many of same problems. These are very trivial actions, so, you really need to read the manuals. Start withvimtutor
, go through:h intro.txt
.