home *** CD-ROM | disk | FTP | other *** search
/ ftp.texkom.ru / ftp.texkom.ru.tar / ftp.texkom.ru / Plugins.zip / Plugins / SearchAndReplace / Doc / FAQEng.txt < prev    next >
Text File  |  2003-03-20  |  16KB  |  412 lines

  1. FAQ on "What is Search And Replace and how to eat it..."
  2. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. ADVICE: READ HELP MORE ATTENTIVELY!
  4. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5.  
  6.   This FAQ includes answers for questions, which  I  was  asked  sometimes  by
  7. S_AND_R user (by mail, voice etc.). If you haven't found an  answer  for  your
  8. question here, ask me, and I'll include it (and the answer :-) in this FAQ. If
  9. you've got a question and an answer, and you'd like to see  it  in  this  FAQ,
  10. also send them to me.
  11.  
  12. Maintainer - Ivan Sintyurin/ AKA Spinoza
  13. (spinoza@mail.ru, http://www.moris.ru/~spinoza)
  14.  
  15. ───────────────────────────────────────────────────────────────────────────────
  16. In no answer author given, it means, the author is me.
  17. Currently, answers of the following people have been used in FAQ:
  18. IR -> Igor Ruskih (ruiv@uic.nnov.ru)
  19. AY -> Alex Yaroslavsky (totrtx@barak-online.net)
  20. ───────────────────────────────────────────────────────────────────────────────
  21. VERSION OF [Thu 06 Mar 19:45:32 2003]
  22. Legend:  * - questions with changed/added answers
  23.          + - new questions
  24.  
  25. ALL OF THE FOLLOWING IS RIGHT ONLY FOR S_AND_R VERSION 2.1 AND LATER
  26. (maybe, it will work in older versions, but I'm too lazy to try :-)
  27. ──────────────────────────────────────────────────────────────────────────────
  28. [0] I've found a terrible bug!!!
  29. [1] What's this, at the end?
  30. [2] What about search and replace with regular expressions?
  31. [3] What, if I want to replace 5 different words?
  32. [4] What, if I want to replace 1000 different words?
  33. [5] I want to search, using all available code pages?
  34. *[6] I've got a heap of files, in which there are unneeded spaces in the end
  35.     of lines. It's boring to call Trucer for every file. What can I do?
  36. *[7] Got a heap of files. Want to replace many null lines into one. How to do?
  37. [8] ... and if I want to delete all the null lines?
  38. [9] What are all these regexps needed for, in the end?
  39. [10] These regexps are such a great thing. Thanks!
  40. [11] I want to do this and that, use such a regexp for it, and got
  41.      a question...
  42. [12] Wanna delete the line, containing word blablabla. How to do it?
  43. [13] I use regexps. I have made a little mistake, and your [censored] plug-in
  44.      have replaced everything in my file in absolutely improper way.
  45. [14] Why does it work so badly?
  46. [15] I want to lowercase all the tags in html-file.
  47. [16] How to delete all of these tags, in the end?
  48. [17] Cannot search with hex-codes using simple search (w/o using regexps)...
  49. [18] What regexp means end of the line, in the end?
  50. [19] When will it be possible to use in editor?
  51. [20] What shit is all this? Searching with file-mask *.* causes bak-files
  52.      to create...
  53. [21] I want the same kind of menu for opening a file in a viewer, as using
  54.      shift-f4. How can I do it?
  55. [22] Why do you overload the plug-in with s&r:view etc?
  56. [23] I want to search words...
  57. [24] I want plug-in automatically to start, when I press enter on it's
  58.      configuration file.
  59. [25] Your regexps handling is too slow :(
  60. [26] This plug-in can numerate lines, can't it?
  61. [27] How can I sweep a vertical block in editor?
  62. [28] Why doesn't s&r allow to "glue" lines in editor?
  63. [29] Your ctrl-up/down macros produce bugs with mousewheel.
  64. [30] I want to place found files on temp panel.
  65. [31] How can I specify search area "Search in the current folder only"
  66.      etc. (similar to alt-f7)?
  67. [32] How to delete the duplicated strings from a file?
  68. [33] How to swap everything in each line of the editor all, what is arranged
  69.      up to the character '=' and after this character?
  70. [34] The item of the plugin module is added in the "plugins menu" of the FAR
  71.      only after of the first execution of the S&R in panels or in the editor.
  72. [35] How to write regexp equal to  "text1  --  any  symbols  sequence  except
  73.      empty line -- text2"?
  74. [36] VerInfo: How to view version information for a file on archive panel?
  75. [37] Replacement "^$" with "" does not delete  empty  lines  even  if  option
  76.      "replace options/delete empty lines" is set.
  77. *[38] Is it true S&R can replace standard FAR "Temporary panel" plugin?
  78. +[39] How can I make S&R settings to be the same always when FAR starts?
  79. [40] How can I use the lookahead/backward search regexp's operators?
  80. [41] Why does message "Search string is empty!" appear when I want to search
  81.      a regexp, which starts from '/' symbol?
  82. +[42] Why are you using an archive, which is enveloped into another  one,  for
  83.      distribution of S&R?
  84.  
  85. Here your question could be...
  86.  
  87. ──────────────────────────────────────────────────────────────────────────────
  88. [0] I've found a terrible bug!!!
  89.  
  90.     Everything could happen :-) If you wish bug to be found and cut  out,  send
  91. me the following information:
  92.  - bug description and sequence of actions led to it
  93.  - S&R/FAR/Windows version
  94.  - Data from: HKCU\Software\Far\Plugins\S_And_R
  95.    (of from HKCU\Software\Far\Users\UserName\Plugins\S_And_R, if you execute
  96.     FAR by command: far /u UserName)
  97.  - size of file, on which the bug have occurred
  98.  - CPU/size of HDD, on which the file is written/it's free space/RAM size
  99.  - S&R/FAR/Windows last message
  100.  - any additional information, that seems to you useful
  101.  
  102.  DO NOT SEND:
  103.  - screenshots (except those, which have been created with ALT+INS), large
  104.    attaches etc.
  105.  
  106. [1] What's this, at the end?
  107.  
  108.     It's a virus. Hypnoses people, makes them copying it with increasing speed,
  109. changing some vital bytes in your file (of course, without asking  you  first!)
  110. :-)))
  111.  
  112.     Seriously - short answer to this question is in readme.txt, and even  I  do
  113. not know the full answer - the application are of this program is very large.
  114.  
  115. [2] What about search and replace with regular expressions?
  116.  
  117.     Invented in version 0.3
  118.     Just set the corresponding option.
  119.  
  120. [3] What, if I want to replace 5 different words?
  121.  
  122.     Currently, there is the only way for doing it - to run the program  5 times
  123. (the most convenient way is to run it from user menu  with  different  settings
  124. file). In the future, maybe, it'll be possible to make such a multi-replacement
  125. at once...
  126.  
  127. [4] What, if I want to replace 1000 different words?
  128.  
  129.     Listen, guy, won't PROMT help you in this case? :-)
  130.  
  131. [5] I want to search, using all available code pages?
  132.  
  133.     Appeared since version 1.8.
  134.  
  135. *[6] I've got a heap of files, in which there are unneeded spaces in the end
  136.     of lines. It's boring to call Trucer for every file. What can I do?
  137.  
  138.     There are two ways, but they won't work for the last line of the file,
  139. if it doesn't end with end of line symbols (and that's right).
  140.  
  141.     [x] Regular expressions
  142. Variant 1 (for files with lines ending with \r\n):
  143.        Search=\x20+\r\n   (or "\x20+$", see configurations)
  144.        [x] Replace with=\$
  145.  
  146. Variant 2 (universal): Search=\x20+(\r?\n)
  147.                            [x] Replace with=$1
  148.  
  149.      Both variants are intended to be used in panels. In editor you may use the
  150. following:
  151.      [x] Regular expressions
  152.      Search=\s+$
  153.      [x] Replace with=(null string)
  154.      You may turn off option "[ ] Delete empty lines", if you do not want  S&R
  155. to delete lines, which consist of spaces only.
  156.  
  157. *[7] Got a heap of files. Want to replace many null lines into one. How to do?
  158.  
  159.     In panels:
  160.     Search=(\r\n){2,}
  161.     [x] Replace with=\$\$
  162.     [x] Regular expressions
  163.  
  164. [8] ... and if I want to delete all the null lines?
  165.  
  166.     Then:
  167.     [x] Replace with=\$
  168.  
  169. [9] What are all these regexps needed for, in the end?
  170.  
  171.     You, as far as you ask such a question, don't need them...
  172.  
  173. [10] These regexps are such a great thing. Thanks!
  174.  
  175.     Don't forget to thank Konstantin Stupnik, I use his regexps parsing module
  176. in the S&R.
  177.  
  178. [11] I want to do this and that, use such a regexp for it, and got
  179.      a question...
  180.  
  181.     Send all questions to me or read books :-)
  182.  
  183. [12] Wanna delete the line, containing word blablabla. How to do it?
  184.  
  185.     [x] Replace with=\$
  186.     [x] Regular expressions
  187. IR> Search=\r\n[^\n]*blablabla[^\n]*\r\n
  188. Alternative variant:
  189.     Search=^[^\n]*blablabla[^\n]*\r\n
  190.  
  191. Note:
  192.     Starting with version 1.0 this regexp is right, when option "Process
  193.     several lines" is set. If it is not set, you can use regexp like:
  194.     Search=\r\n.*blablabla.*\r\n
  195.  
  196.     In editor you may use:
  197.     [x] Regular expressions
  198.     [x] Delete empty lines
  199.     Search=^[^\n]*blablabla[^\n]*\r\n
  200.     Replace with=(null string)
  201.  
  202. [13] I use regexps. I have made a little mistake, and your [censored] plug-in
  203.      have replaced everything in my file in absolutely improper way.
  204.  
  205.     1. DO NOT WRITE IRREGULAR REGEXPS!
  206.     2. [x] Save original file copies
  207.     3. [x] Replacement confirmation
  208.  
  209. [14] Why does it work so badly?
  210.  
  211.     a) What makes you saying "badly"? (maybe, something may be corrected)
  212.        See also FAQ#0
  213.     b) Write the same yourself, egg-head
  214.  
  215. [15] I want to lowercase all the tags in html-file.
  216.  
  217.     Search=<.+?>
  218.     [x] Replace with=\L$0
  219.     [x] Regular expressions
  220.  
  221. [16] How to delete all of these tags, in the end?
  222.  
  223.     Search=<.+?>
  224.     [x] Replace with=(null string)
  225.     [x] Regular expressions
  226.  
  227. [17] Cannot search with hex-codes using simple search (w/o using regexps)...
  228.  
  229.     They'll be searched only in case sensitive mode, i.e. it should be:
  230.     [x] Case sensitive
  231.  
  232. [18] What regexp means end of the line, in the end?
  233.  
  234.     Use "\r\n" (or "$", see configuration), "\n" or universal - "\r?\n".
  235.     See also FAQ#6
  236.  
  237. [19] When will it be possible to use in editor?
  238.  
  239.     It is possible starting from version 1.0
  240.  
  241. [20] What shit is all this? Searching with file-mask *.* causes bak-files
  242.      to create...
  243.  
  244.     Completely cured in version 1.1.
  245.  
  246. [21] I want the same kind of menu for opening a file in a viewer, as using
  247.      shift-f4. How can I do it?
  248.  
  249.     S&R starting with version 0.9 can't help you... Use  Far Commands  plug-in
  250. from Far distribution.
  251.  
  252. [22] Why do you overload the plug-in with s&r:view etc?
  253.  
  254.     No such things anymore. I threw them away in version 0.9.
  255.  
  256. [23] I want to search words...
  257.  
  258.     If you use regexps search, see help on special characters \b.
  259.     If you use simple search, set "[x] Whole words only".
  260.  
  261.  
  262. [24] I want plug-in automatically to start, when I press enter on it's
  263.      configuration file.
  264.  
  265.     To do it,  you  should  create  configuration  files  with  some  original
  266. extension, i.e. ".sr".  Then  it  will  be  possible  to  make  the  following
  267. association to "*.sr" files on the Enter key:  "s&r:i/!\!.!".  After  that  to
  268. run plug-in you'll be able just to press Enter on "*.sr" files...
  269.  
  270. [25] Your regexps handling is too slow :(
  271.  
  272.     Work with regexps is performed by Konstantin  Stupnik's  parser.  Ask  him
  273. about things, concerning parser work speed...
  274.  
  275. [26] This plug-in can numerate lines, can't it?
  276.  
  277.     Yes, it can. Use replacement string regexp "\#" to perform it...
  278.  
  279. [27] How can I sweep a vertical block in editor?
  280.  
  281.     Search for=.
  282.     Replace with=\x20
  283.     [x] Regular expressions
  284.     () Selected text
  285.  
  286. [28] Why doesn't s&r allow to "glue" lines in editor?
  287.  
  288.     'Cose there's no standard method to do it in Far. Of course, it's possible
  289. to solve the problem without using Far, but it will cause plug-in  work  speed
  290. in editor to decrease _essentially_. If you wish  to  work  with  EOL  symbols
  291. more productively (including, you wish to "glue" lines), run s&r in panels and
  292. process the file you need.
  293.  
  294. [29] Your ctrl-up/down macros produce bugs with mousewheel.
  295.  
  296.     Put these macros to any other keys :)
  297.  
  298. [30] I want to place found files on temp panel.
  299.  
  300.     Appeared since version 1.6, it may be turned on in "Configuration/Search",
  301. but it works only in FAR 1.70 and later versions.
  302.  
  303. [31] How can I specify search area "Search in the current folder only"
  304.      etc. (similar to alt-f7)?
  305.  
  306.     a) "Search in all non-removable drives"
  307.        () Search in folders: *
  308.        [x] Process subfolders
  309.  
  310.     b) "Search from the root folder"
  311.     No perfect analogue, you'll have to specify the path, or jump to disk's
  312. root folder and start searching there.
  313.  
  314.     c) "Search from the current folder"
  315.        () Search with file-mask
  316.        [x] Process subfolders
  317.  
  318.     d) "Search in the current folder only"
  319.        () Search with file-mask
  320.        [ ] Process subfolders
  321.  
  322.     e) "Search in selected folders"
  323.        () Search in selected
  324.  
  325. [32] How to delete the duplicated strings from a file?
  326.  
  327.     For example...
  328.     In panels set cursor to file, invoke S&R.
  329.     () Search in selected
  330.     Search for=^(.+\r\n)\1+
  331.     Replace with=$1
  332.     [x] Regular expressions
  333.     [ ] Process several lines
  334.  
  335. [33] How to swap in each line of the editor all, that is arranged
  336.      up to the character '=' and after this character?
  337.  
  338.     Search for=^(.*?)=(.*?)$
  339.     Replace with=$2=$1
  340.     [x] Regular expressions
  341.  
  342. [34] Item of the plugin module is added in "plugins menu" of FAR
  343.      only after the first execution of S&R in panels or in editor.
  344.  
  345.     Clear your plugins cache (you may use ClearPluginsCache.bat)
  346.  
  347. [35] How to write regexp equal to  "text1  --  any  symbols  sequence  except
  348.      empty line -- text2"?
  349.  
  350.     [x] Regular expressions
  351.     [x] Process several lines
  352.     Search=text1((?!\r\n\r\n).)+?text2
  353.     "\r\n\r\n" means empty string - two eol-sequences if DOS  format.  If  you
  354. work with file in unix-format you may use:
  355.     Search=text1((?!\n\n).)+?text2
  356.     Universal variant:
  357.     Search=text1((?!\r?\n\r?\n).)+?text2
  358.  
  359. [36] VerInfo: How to view version information for a file on archive panel?
  360.  
  361.     You must open a file in the viewer (F3) and execute VerInfo there.
  362.  
  363. [37] Replacement "^$" with "" does not delete  empty  lines  even  if  option
  364.      "replace options/delete empty lines" is set.
  365.  
  366.      S&R cannot replace something if its size is 0.  The work will be  stopped
  367. in panels in such case. In editor the work will not stopped, but  replacements
  368. won't be preformed. If you want to  delete  empty  lines,  use  the  following
  369. command: "F11/S&R/Delete not matched lines" and regexp ".".
  370.  
  371. *[38] Is it true S&R can replace standard FAR "Temporary panel" plugin?
  372.  
  373.      Yes, it's  possible  in  S&R  2.0  and  above.  If  you  delete  standard
  374. TmpPanel.dll, FAR found files list (Alt-F7) will be placed  to  S&R  temporary
  375. panel (of course, temppanel.srs must be installed, FAR version  must  be  1.70
  376. build 1282 and above, option "Process OPEN_FINDLIST command" must  be  set  in
  377. configuration of temppanel.srs).
  378.  
  379. [39] How can I make S&R settings to be the same always when FAR starts?
  380.  
  381.       Export necessary settings into s_and_r_settings.reg and import  it  when
  382. FAR starts. You can import them with "regedit -s s_and_r_settings.reg" command
  383. using FAR autostart macro, for example.
  384.  
  385. [40] How can I use the lookahead/backward search regexp's operators?
  386.  
  387. AY> You can use the lookahead/backward search  regexp's  operators  to  search
  388. AY> text, which is placed before/after any other text, which you not  want  to
  389. AY> match with search regexp (useful for replaces).
  390. AY> Examples:
  391. AY> 1. Search=(?<=AA)YYY
  392. AY>    Replace with=X
  393. AY>    Perform replacement "YYY" with "X" if text "AA" exists before "YYY".
  394. AY> 2. Search=AA(?=YYY)
  395. AY>    Replace with=X
  396. AY>    Perform replacement "AA" with "X" if text "YYY" exists after "YYY".
  397.  
  398. [41] Why does message "Search string is empty!" appear when I want to search
  399.      a regexp, which starts from '/' symbol?
  400.  
  401.      If  you  use  regexp  "/bla/"  this  message  appears  only  if   "search
  402. options/Work without // when searching with regexps" option is set, because in
  403. this case S&R appends these slashes, which results in "//bla//".  This  regexp
  404. is empty, because regexp is a text, which is placed between first two slashes.
  405.  
  406. +[42] Why are you using an archive, which is enveloped into another  one,  for
  407.      distribution of S&R?
  408.  
  409.      This is the simplest sieve, which allows to separate losers from users :-)
  410.  
  411. ───────────────────────────────────────────────────────────────────────────────
  412.