Notepad++ sort by line length11/14/2022 ![]() ![]() Insert enough spaces so that the shortest line of data will be padded out to the length of the longest line of data. Then in the Edit menu select Column Editor. Place the text cursor (the vertical line) into the very first position of the file. Reverse all lines first if you want to sort longest to shortest. Note that this will retain the original ordering when sorting from shortest string to longest string. Choose "Number to Insert" and start with 1, increase by 1, and include leading zeros. But the reason for adding the line numbers, is so we know the natural order, so that when for example, two+ lines are of equal length we can sort those lines according to that natural order)Īssuming your text file only has the data in it, place the text cursor (the vertical line) into the very first position of the file. (Note added by barlop- a note for the reader regarding this step, we will not be sorting according to these line numbers, we're sorting according to the length of the lines. I'll use the following as example data: Lorem The idea in this answer is to add spaces and line numbers so that _092dog will be sorted above _003alligator. _X (pretending the underscores are really spaces) will similarly come alphabetically before _XX. "The Zoo" comes alphabetically before "Their House" because the space is treated as a character and comes before "i". This tool can be hijacked to sort by the length of the lines by placing spaces on the left of each line, and making sure that all the lines are the same length. Notepad++ has a built-in TextFX tool that sorts selected lines alphabetically. Updated to maintain original sort order, if that is important. I think I’d have to see this in action to understand it.This answer is inspired by a YouTube video. Soft highlights all occourances of that, but not selected/mult-edit highlight… ![]() lLineRight() //Delete from the cursor to the EOL This is another Komodo JavaScript macro Some simple things like “delete to end of line” are available using a four-line macro: //. Macros are best for this kind of operation. ![]() Use the default sort here, or write your own sorter. It's easy enough to find that and remove it. It also assumes there's no trailing empty line. This assumes a certain line ending, for simplicity. Access the current editor's internals. Without the comments, this is just a 10-line macro: //. This also lets you sort however you want. I’m not aware of a built-in binding, but it’s easy enough to write a macro to do the work. Sort asc/dec, lexically or numerically, or alpha numerically… I think it’s reasonable to request a behavior change for that, since the presence of a selection essentially moots the value of moving the cursor position. The second binding moves the cursor to the other brace when it’s called repeatedly, like the “jump” but with a selection. There are two built-in key bindings that get you most of this:Ĭode: Jump to Matching Brace and Code: Select to Matching Brace. Hotkey to make selection between the two, pressing again expands selectin more and more Hotkey to jump to matching curly, parenthesis, single, double quot, html tag, etc. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |