Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to modify code so that the comment at the end of a line is moved to the beginning of the (new) line above. Are there editors that support this (I'm using NotePad++) an what would this be called?

share|improve this question
Moved from where? Can you supply an example of what it looks like before, and how you want it to look after? – Ƭᴇcʜιᴇ007 Aug 5 '11 at 15:32
up vote 1 down vote accepted

I don't know what you would call it, but in Vim it is pretty easy to record an action that would:

  1. Find the first comment character
  2. delete to the beginning of the line
  3. make a new line
  4. insert the deleted text

For an even more generic solution it supports full regular expressions so you could do it on the entire document that way.

share|improve this answer
I've never used macros, but this also works with Notepad++. – temp Aug 5 '11 at 15:54
While I love Vim it does have a learning curve. So if Notepad++ will do it for you I would accept Nathan's answer instead of mine. – EBGreen Aug 5 '11 at 15:56

Notepad++ has a Macro feature. You can play with that and see if it does what you need it to do. For example, hit "start recording", search for "a", and then "stop recording". Then, Ctrl-Shift-P will allow you to search your whole document for 'a'. This is a simplistic explanation but you can get really complicated with the macro feature and get it to do pretty much anything you need.

share|improve this answer
I'm suggesting to use notepad++ because vim has a steep learning curve if you've never used it before. – Nathan Garabedian Aug 5 '11 at 15:46


:map q 0f#i<Ctrl-V><Return><Ctrl-V><Esc>ddkP

(Assuming comments start with a #.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.