Hacker News new | ask | show | jobs
by dchest 5246 days ago
Don't all editors work this way?

Seems like my description was incorrect. I meant that there are two ways to deal with text: line-wise and fragment-wise.

In most other text editors, if you copy a line, and then paste it, it gets pasted into the cursor position regardless whether you copied a line or a fragment (fragment-wise). In Vim, lines yanked with 'yy' disregard the cursor column and get pasted into a line above or below, while fragments yanked with 'y' (e.g. '0y$'), take into account the column.

I like how in Vim you can do line-wise editing, but I just miss an easy way to paste text to the position starting with the current column regardless of the way I yanked it.

PS Thanks everyone for replies!

1 comments

you can always map <leader>y to yank line except for end.

Mapping the leader to , and it's even nicer. then all you need to do is ,y and you get the line in fragment mode.

nnoremap <leader>y 0y$

or if you want just first non whitespace char you could do an uppercase y for the leader command. swap the upper and lower to make it how you want. seems like this would be a more useful command to have:

nnoremap <leader>Y ^y$

edit: saw that you found a workaround by pasting in insert mode. ctrl-r" any other ways to paste in insert mode?