tags:

views:

1578

answers:

4
+10  Q: 

Extend Notepad++

Hi!

As I use Notepad++ daily at work, I want to extend it to be more productive.

What i want to do is select multiple lines containing words, right click and click a menu item like "Comma separate" then get all words on a single line comma separated.

I know that Notepad++ has support for macros and plugins. What would be the best way to do this?

I've got limited C++ skills.

Update:

To clarify, it's never more than 5 or 6 lines of words i need to re-format. The problem is that I do this like 50 times a day, so a way to speed up this would be great. Is there any other application that can do this for me?

Update2

Thanks for your answers. I'm going to try creating a Notepad++ plugin.

Update3

Does anyone know of a .NET-wrapper to create a Notepad++ plugin? Maybe this should be a new question.

A: 

Let see. I have 5 lines of word. I select them. Ctrl+H. Check Extended and In selection. Search '\r\n', replace with ',', hit Replace All. I got mostly the result you want (with an extra comma at the end).

Is that what you want? Perhaps you can make a macro out of it, I don't know much about this capability (I mostly use SciTE actually).

PhiLho
Yes, this is the behaviour i'm after. Unfortnuately, this won't save me that much time, as it's often just 5 or 6 lines of words.
alexn
PhiLho SciTE really rocks.
mahesh
Tried with latest Notepad++, it still doesn't make macros out of Find/Search dialogs (probably use Scintilla's macro capability).Unless I miss something, I fear you have to write a C++ plugin, which is a bit of overkill for your need. Too bad NPP doesn't support scripting like SciTE does. It would be quite trivial to do in Lua...
PhiLho
+2  A: 

I often use Notepad++'s macro function for things like this.

Eg. Say you have this:

apple
pear
banana
grape
orange

To comma separate lines, you could go to the first line, press ctrl+r (start recording), then end, delete, comma, then ctrl+r again to stop recording.

Then press control+p (play recording) repeatedly until you have what you want. If I'm processing a large file, I just hold it down, then ctrl+z my way back if I go too far.

You can't save your macro for later, but something that simple is easy to do again.

Edit: Actually, it turns out you can save your macro for later, and even assign a hotkey to it. Just record the macro, then go Macro -> Save current recorded macro.

Blorgbeard
Unfortunately, this solution won't save me time as it's often just 5 or 6 rows i need to replace.
alexn
+1  A: 

Actually in Notepad++ you have to use this string to match single word in a line, possibly with trailing spaces:

^\<(.*)\> *$

and then you replace the words with \1,

I tried to do this myself, everything worked, except after this you have to switch from regex search mode to extended and delete all \r\n or \n depending on your line endings.

Malcolm
A: 

You can do this easily now with the Python Scripting plugin for Notepad++.

Just add a script with something like

text = editor.getSelText()
text = text.replace(' ', ',')
editor.replaceSel(text)

Assign the script a shortcut or toolbar button and you're away. I'm not totally clear on what you want to replace, but obviously changing the logic of the script should be pretty easy.

Dave Brotherstone