News for hackers. Stuff that matters.
Re:Why, oh why, do those nutheads use vi? by austintaylor on Thursday February 02, 2012 @10:09AM (#3542940)
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>".

Re:Why, oh why, do those nutheads use vi? by dchest on Thursday February 02, 2012 @10:36AM (#3543055)
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!

Re:Why, oh why, do those nutheads use vi? by weaksauce on Thursday February 02, 2012 @06:40PM (#3545089)
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?

Re:Why, oh why, do those nutheads use vi? by Symmetry on Thursday February 02, 2012 @10:16AM (#3542975)
Vim'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
Re:Why, oh why, do those nutheads use vi? by dchest on Thursday February 02, 2012 @10:38AM (#3543062)
Yes, 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!