1. 0y$p
and
2. o<ESC>p
" 'Inside-line' operator-pending-mode mapping
onoremap <silent> il :<C-U>normal! ^v$h<CR>
onoremap <silent> iL :<C-U>normal! 0v$h<CR>That is, i<C-r>0 will paste a line character-wise, but the EOL will still be there, so you might have to join lines afterward. Alternatively, you could not yank the EOL with ^y$.
For making a newline with a character-wise yank, use o or O to make the new line and you can use <C-r>0. Or Escape and p.
If you want to yank a line character-wise, you would do something like ^y$. I have Y mapped to y$ for this sort of thing.
You cannot yank a substring of a line line-wise. That doesn't really make sense. I typically open a new line with o and then paste in insert mode with <C-r>". So o<C-r>".
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!
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?
This is a test
^
with your curser at the carrot, and you type 'yyp' you will get This is a test
This is a test
Rather than This This is a test
is a testEdit: aha, pasting in insert mode works like this!
1) 'J' to join the two lines after paste
2) o<esc>p or O<esc>p
Perhaps there's an even "easier" way, but for me these keystrokes have long been recorded to muscle-memory, I don't even notice them anymore.
vnoremap <silent> al :<c-u>norm!0v$h<cr> vnoremap <silent> il :<c-u>norm!^vg_<cr> onoremap <silent> al :norm val<cr> onoremap <silent> il :norm vil<cr>
The 2nd can be o/O<esc>p .. Maybe there's a more elegant way though!
You could bind these to, say, <leader>p and <leader>P, if you find yourself doing it a lot.
map Y y$Use an editor you can use right away and whose controlls don't contradicts with the rest of the software you use.
I don't believe in vim neither I don't belive in plain Emacs.
Just my 2 cents
As for the controls that contradict with the rest of the software, there's no trouble for me at all. I don't suddenly start pressing :wq in the browser. As a simple example, consider people like me, who use two keyboard layouts: one for their native language and the other one for English. Even punctuation marks are on the different keys, but I don't have trouble typing the correct ones depending on the current layout.
This is why I use ErgoEmacs :)
1) If I yank a line with yy, pressing P or p will insert the text into a new line.
2) If I go to visual mode and select a region, yank it with y, then press p/P, it gets it inserted into the current line.
That is, vim preserves new lines.
What I can't figure out is how to paste into the current line in the first case, and, vice-versa, how to easily paste into a new line in the second case (without doing :put, or opening a new line).