ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Text editor with filtering of lines

(1/7) > >>

vixay:
This has been driving me nuts.
I need a text editor that can do filtering of lines in view like dopus. If you have ever used dopus you know that you can filter the visible files by typing wildcard masks (e.g. *txt) ...etc

What I want is something similar but for lines in text files, using regex/wildcards/characters. Almost all editors (ultraedit, pspedit, notepad++) have this feature in find and replace, with ability to list output in separate window ...etc but none do it in place.  

This is basically useful for when i need to find certain types of lines in files and edit them. Visually narrowing the file from a bunch of lines to just a few entities that I'm interested in quickly to edit is very appealing and necessary!
Especially for log files, xml files ...etc.

The key difference is I want to have it in-place (i.e. in the editor window itself). The editor can collapse the other lines or hide them from view in another way, I don't care.
Similar to incremental search, but this is incremental filtering.
Similar to Find all, but this is in editor view
 

Does anybody know of  any text editor that can do this? I bet emacs can but I don't know how, I wouldn't mind using that as my default text editor if it did this!

/edit: an editor, not a viewer, I know grep and other viewers exist for filtering lines.

mouser:
that's an interesting feature idea for a mini text editor.

MilesAhead:
Not sure if it's exactly what you want but you could try vim.  It has views and somebody mentioned folding.  It may be useful and there are Windows ports of it for free.  May be worth a look anyway.

vixay:
I have gVimPortable installed, and i fired it up, loaded a file, and then i'm lost. Do you have any specific directions?

/edit: found the following after looking through the help files that could help. Any idea on how it would work for say 'fold all lines that don't contain the string popup'

--- ---==============================================================================
*28.8* Folding by expression

This is similar to folding by indent, but instead of using the indent of a
line a user function is called to compute the fold level of a line.  You can
use this for text where something in the text indicates which lines belong
together.  An example is an e-mail message where the quoted text is indicated
by a ">" before the line.  To fold these quotes use this: >

:set foldmethod=expr
:set foldexpr=strlen(substitute(substitute(getline(v:lnum),'\\s','',\"g\"),'[^>].*','',''))

You can try it out on this text:

> quoted text he wrote
> quoted text he wrote
> > double quoted text I wrote
> > double quoted text I wrote

Explanation for the 'foldexpr' used in the example (inside out):
   getline(v:lnum) gets the current line
   substitute(...,'\\s','','g') removes all white space from the line
   substitute(...,'[^>].*','','') removes everything after leading '>'s
   strlen(...) counts the length of the string, which
is the number of '>'s found

Note that a backslash must be inserted before every space, double quote and
backslash for the ":set" command.  If this confuses you, do >

:set foldexpr

to check the actual resulting value.  To correct a complicated expression, use
the command-line completion: >

:set foldexpr=<Tab>

Where <Tab> is a real Tab.  Vim will fill in the previous value, which you can
then edit.

When the expression gets more complicated you should put it in a function and
set 'foldexpr' to call that function.

More about folding by expression in the reference manual: |fold-expr|

==============================================================================

mwb1100:
EditPad Pro.  There's a "Fold" option in the search panel that does exactly this.

Navigation

[0] Message Index

[#] Next page

Go to full version