3

I'm looking for the best way to append the previous line to the current line like this:

# Bazzy Comment
foo = 'bar'

To this:

foo = 'bar' # Bazzy Comment

Currently I can do this:

From top line dd,p,k,Shift+J

Yank Link, paste, move cursor up, Join Lines

Basically I'm looking for a backward line join. I feel like there must be a better way to do this.

Dakota K
  • 141
  • 1
  • 5
  • if you just do this occasionally, and only backwards join single line, leave with your solution, or like doelleri suggested, create a mapping. If you need backwards join multiple lines, there is plugin to do it. – Kent Mar 12 '15 at 21:38
  • possible duplicate of [How do I Join the line above after current line?](http://stackoverflow.com/questions/13609736/how-do-i-join-the-line-above-after-current-line) – glts Mar 12 '15 at 21:44

2 Answers2

2

Your method seems good to me.

ddpkJ

In a different editor you would do the following steps: select line, cut, delete blank line, move to end, enter space, and paste. So in Sublime Text it would be <c-l><c-x><end><space><c-v><del>.

Vim does it with less key strokes and less modifiers. I guess if you do this a bunch then you can speed this up by making a mapping.

Personally I would just leave it be and put efforts into more time consuming operations.

Peter Rincker
  • 43,539
  • 9
  • 74
  • 101
1

There isn't a builtin command for this. You can nnoremap those keys to another keystroke though. For example,

:nnoremap <M-J> ddpkJ
doelleri
  • 19,232
  • 5
  • 61
  • 65