3 ms·
Whether it pastes a newline or not depends on whether you yanked one. I guess this is what you mean by "vim preserves new lines". Don't all editors work this wa
by austintaylor 15y ago
Whether it pastes a newline or not depends on whether you yanked one. I guess this is what you mean by "vim preserves new lines". Don't all editors work this way?
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>".
- Symmetry 15y agoVim's preserving of new lines is more awesome than that of lesser editors. If you have 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 test
- dchest 15y agoYes, but can you make it paste the second way if you yanked with 'yy'? That's my problem. Edit: aha, pasting in insert mode works like this!
- dchest 15y agoDon'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!
- weaksauce 15y agoyou 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?
- deleted 15y ago[deleted]