frew Posted September 3, 2008 Posted September 3, 2008 Hello,I'm wondering if it's possible to search and replace multiple lines with Scite?I do some html editing with the Scite full version that comes with AutoIt, and sometimes I need to be able to select a few lines in a file, then replace these few lines with some other lines...and do this replacement through many files.The "replace in buffers" works great to replace all matching lines in all the open files with another line, but the appears to be a limitation of one line at a time that can be replaced.Any ideas on how to replace a group of five or ten lines at once?I refer to continuous lines, like lines 20 though 25 for example.I have not tried this yet:http://www.autoitscript.com/forum/index.ph...ple+lines\which I found when I searched the forum for "replace multiple lines".I'm kind of new to this so I was not sure what to do with that code.Thanks for any ideas.frew
MilesAhead Posted September 3, 2008 Posted September 3, 2008 I am new to Scite myself so if there's methods to do what you need I don't know. But if you find youoften get into very complicated editing and pattern substitution and are not afraid of a learning curve,you might consider a Windows port of the Unix/Linux editor vi.I absolutely hated vi when I first tried it, but when playing around with Linux for awhile I tried using it for a bit. It was enough for me to understand why those who get into vi insist on using it. You can enter very powerful commands on the command line inside the editor to change whole ranges of text very quickly once you have acclimated to it.There are free versions for Windows. Just google and see what you find.It definitely requires a learning curve and has a command mode/edit mode toggle that puts people off at first, but if you continue to mess with it you may find you get very fast at doing edits once you get over the initial hurdle. My Freeware Page
avery Posted September 3, 2008 Posted September 3, 2008 I do it all the time with Ctrl+H. Maybe I misunderstand the question. I still use 'WinVI' sometimes but not for this type of thing. www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org
frew Posted September 3, 2008 Author Posted September 3, 2008 I tried vim a little, but need to get used to it. Not sure about vi (is that vim?) And what about cream for vim perhaps? Also, Ctrl+H seems to work for one line at a time, but I need to select multiple lines, go to search and replace, and replace those multiple lines with another set of multiple lines across many files at once. For example, 25 text files all have this continuous group of lines: 1 2 3 4 5 In file1 I want to select this continuous group of lines: 2 3 4 And then have Scite replace all occurrences of the continuous group of lines: 2 3 4 that it finds in any (or all) of the 25 files, with this continuous group of lines: cat dog expanding_universe So that the group of lines that were: 1 2 3 4 5 will now be this instead: 1 cat dog expanding_universe 5 Thanks for any ideas.
MilesAhead Posted September 4, 2008 Posted September 4, 2008 Without getting into the particulars, if you have frequent need of complicated text editing/substitutions then it's worth your time to look into the many Linux ports to Windows. Most you can get for free. Other than an editor per se, you can also use command line editing such as sed pattern match utilities like awk and also I think you can do a lot with Perl one-liner scripts.. although the syntax has some learning curve. Sed and awk are pretty easy to use though.They may not be helpful in this case but good to have in your toolbox. My Freeware Page
IvanCodin Posted September 6, 2008 Posted September 6, 2008 You might want to look a this site: http://unxutils.sourceforge.net/Me
frew Posted September 6, 2008 Author Posted September 6, 2008 Thanks for the ideas. I hope to have a simple solution. I'm using Windows98SE and do not know much about command line or other platforms, programing, etc. I found something that I think may work: jEdit ...but I was hoping that Scite may do it. I'm quite new to AutoIt, and I have been using the Scite that comes with AutoIt. For now, I just utilize AutoIt to do basic automation of mouse movements and mouse clicks for repetitive tasks...and lots of sending of keys with Send(). I like Scite so much that I started to use it to do HTML work, but find that I cannot do search and replace of multiple lines throughout multiple files that I have open in Scite. (Single line search and replace through multiple open files works great though.) Thanks for any other ideas.
MilesAhead Posted September 8, 2008 Posted September 8, 2008 Thanks for the ideas.I hope to have a simple solution.I'm using Windows98SE...One thing about the Unix/Linux command line based tools, they are small and fast, will run fine on Win98, and once you learn 'em, they don't change much. A sed one-liner file filter from 10 years ago probably still works. Just a thought. (plus you can't beat the price) My Freeware Page
frew Posted September 9, 2008 Author Posted September 9, 2008 Thanks for the ideas. Sed seems way over my head. I don't want to have to learn that much in order to do multi-line search and replace throughout multiple files. So it appears that perhaps Scite cannot do this at this time. Thanks for your ideas. frew
Nevin Posted September 9, 2008 Posted September 9, 2008 In Scite, Ctrl-H has a "Replace all" button. I've also pasted my code over to Word and done the replace there in the past. I'm not sure why. Maybe the full Scite has replace all and the small version doesn't?
Stilgar Posted September 9, 2008 Posted September 9, 2008 @frew:jEdit can do this.If you want to use it for AutoIt you can use this extension for jEdit:jEdit 4 AutoIt jEdit4AutoIt PlanMaker_UDF Â Â
MilesAhead Posted September 9, 2008 Posted September 9, 2008 Thanks for the ideas.Sed seems way over my head.I don't want to have to learn that much in order to do multi-line search and replace throughout multiple files.So it appears that perhaps Scite cannot do this at this time.Thanks for your ideas.frewJust about anything that can search and replace over multiple lines is going to use either Regular Expressions, or some other symbolic substitution "language" type of script.If you are doing html pages and style sheets try PsPad. It's free and has Regular Expression search and replace for the current file. I think to do the same replace over multiple files you'll most likely have to either buy an expensive editor, or learn something complicated for a free tool like Emacs, or sed, or vi editor, etc..Try PsPad. It's probably the easiest to use. I use it to do my web site. If you press F10 it previews the page right in the editor. Very nice free software. My Freeware Page
frew Posted September 11, 2008 Author Posted September 11, 2008 Navin, thanks, but I think you may be referring to single lines only.MilesAhead, thanks so much for the idea to try PsPad. I went to their forum and saw a sticky aboutphReplace - A Multiline Search / Replace for PSPadhttp://forum.pspad.com/list.php?2http://www.phdesign.com.au/document.php?pa...tware_phreplaceWow! Seems to work fine with some initial tests. (I'm making backups of my html files first.)Thanks so much for the tip! PsPad looks nice. Nice little html preview too.
MilesAhead Posted September 11, 2008 Posted September 11, 2008 Thanks for the tip on the replace tool. I'm downloading now. My Freeware Page
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now