0

Is there exist a lightweight code editor with the ability of smart reflow of comments, as shown here?

 50-characters column |<---------------------------------------------->| // Initial code if (a == b) { // Test test test test test test test test test test test test test test test test test test test test test } // Then we move the caret on the comment, press // Ctrl-Q and this long line will be splitted into 3 // shorter ones: if (a == b) { // Test test test test test test test test // test test test test test test test test // test test test test test } // Then we may think that the 2nd line contains // some non-relevant information and trim it slightly: if (a == b) { // Test test test test test test test test // test test // test test test test test } // And then, after the 2nd line is trimmed, we press // Alt-Q again and now we have 2 lines instead of 3: if (a == b) { // Test test test test test test test test // test test test test test test test } 

I know, Vim and Emacs probably can do it, but they are too hard to use for me. Also, Visual Studio Code and Sublime Text can do it - sometimes I use them in my work, but currently I need editor which will start faster (instantly) and with less RAM consumption.

5
  • Nowadays, Visual Studio Code is often considered fairly light and fast-starting already! Sublime Text is even lighter and faster. Honestly, I'm not sure you can really do much better than Sublime Text. Why do you need something so light and so fast? Are you on an ancient machine or something? Commented Apr 25, 2018 at 14:33
  • @JohnY My computer is fairly ancient (2010). I need an editor for quick fixes - double-click on some file, make a quick fix in lightweight editor and then close it. Everything should be instantly. Sublime oftenly starts about 3-4 seconds (without plugins) - too long for this case. VSC is cool, but I use it for full-day work, instead of quick fixes. Commented Apr 25, 2018 at 15:40
  • Also, for futher readers: to use this option in Visual Studio Code you need ReWrap extension. It's not possible without it. Commented Apr 25, 2018 at 15:43
  • Since I doubt there is any existing editor that meets your requirements, my suggestion would be to adjust your workflow. For example, always keep a full-featured editor open, and do your quick fixes there. Or write your own rewrapper (not necessarily a plugin for some other editor, but rather with something like AutoHotkey, which would handle copying to the clipboard, rewrapping, and pasting back; so it would look more-or-less like the editor is doing it even though the editor is not involved at all). Commented Apr 25, 2018 at 16:51
  • " Visual Studio can do it" - how? Commented Aug 1, 2018 at 8:21

2 Answers 2

1

CudaText editor can do it with plugin CudaExt.

  • set in user.json option "margin" to some value, e.g. 80
  • install CudaExt via Plugins/AddonManager
  • call F1 dialog, find command "Re-wrap comment at caret"
  • in this dialog, press F9 to set hotkey, e.g. Ctrl+Q

Now you can press hotkey on multiline comment to re-flow it.

CudaExt cmd

1
  • Updated answer, need to set CudaText option "margin" in user.json. Commented Apr 27, 2018 at 18:50
-1

You might want to look into Notepad++, which seems to be nearly as capable as Emacs, but faster and lighter.

7
  • Yes, I already tried as described here: superuser.com/questions/100010/…. It doesn't properly work. Here it is: imgur.com/a/qylRrSh Commented Apr 25, 2018 at 12:31
  • What about a three-step sequence: (1) uncomment, (2) wrap, (3) recomment the wrapped block Commented Apr 25, 2018 at 12:35
  • Hm. In Notepad++ it doesn't actually improve anything, because the second line isn't indented: jsfiddle.net/ozrxdfkg . However, It's interesting idea itself (thanks), and it could work, probably, in some another editor. Commented Apr 25, 2018 at 12:41
  • Did you also spot this question on SuperUser? Commented Apr 25, 2018 at 12:44
  • Yes, after you posted this link :) It doesn't resolve the issue, however. It changes how soft-wrapping looks. Instead, in my example we have to deal with hard-wrapping. Commented Apr 25, 2018 at 12:54

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.