Как использовать расширенное редактирование в Notepad ++ или аналогичном

807
Tonto

Я хотел бы иметь возможность редактировать разделы текста следующим образом.

Я мог бы иметь раздел, как показано ниже.

Пример.

Instance=wall  {  VisGroups=(32) MeshFile=wall.gmt CollTarget=False HATTarget=False  } 

Мне нужно найти нужный раздел на основе имени «Instance» в данном случае «wall», а затем изменить сценарий в строке 4

Я хотел бы изменить CollTarget и HatTarget на True,

Простой случай вырезания / вставки, если это только один или два раза, но это может быть до 500 раз, и разделы будут разбросаны по всему тексту, некоторые области будут иметь один и тот же сценарий, например, CollTarget = False HATTarget = False, который не нужно редактировать. Файл может быть длиной до 5000 строк, как в примере ниже

Instance=object350  {  MeshFile=object350.gmt CollTarget=False HATTarget=False   }  Instance=box056  {  VisGroups=(32) MeshFile=box056.gmt CollTarget=False HATTarget=False   }  Instance=wall01  {  VisGroups=(32) MeshFile=wall.gmt CollTarget=True HATTarget=False   }  Instance=track01  {  MeshFile=track01.gmt CollTarget=True HATTarget=True } 

Также обратите внимание, что строки в скобках не одинаковы


но в следующем разделе я не хочу этого делать.

Instance=20road007  {  VisGroups=(32) MeshFile=20road007.gmt CollTarget=False HATTarget=True Response=VEHICLE,TERRAIN   } 

например, добавить / вставить дополнительный фрагмент сценария или даже полностью удалить его.


Возможно ли это с помощью макроса? Могу ли я что-нибудь сделать в Notepad ++ ..... в нем много команд? Нужно ли мне писать программу на бейсике? Я не понимаю макросов, и мое программирование ограничено.

Как бы я это сделал? Это будет такая экономия времени. Я надеюсь, что я ясно дал понять.

Любая помощь будет принята с благодарностью. Благодарю вас

0
Ваш вопрос неопределенный. Вы предоставляете инструмент, который у вас есть (Notepad ++), и образцы текста, который хотите редактировать, но вы не совсем понимаете, что именно вы пытаетесь выполнить. Для того, чтобы автоматизировать процесс, должно быть что-то верное для изменяемых частей, что не верно для частей, которые должны оставаться неизменными. Что это за пример? Dane 10 лет назад 2

1 ответ на вопрос

1
Jerren Saunders

I'm making a few assumptions, but it appears you want to find all lines that contain

MeshFile=<someValue>.gmt 

then update the parameters for CollTarget and HATTarget to TRUE, without touching any of the other parameters that may be on that line.

Assuming that CollTarget and HATTarget are always the first two parameters, and in that same order, you can run a Replace All command (CTRL+H) on your file and user the following:

Find what = (.*)(wall.gmt) CollTarget=(\w+) HATTarget=(\w+)(.*) Replace with = $1$2 CollTarget=True HATTarget=True$5 

Explanation:

  • See the Notepad++ Regex documentation for general syntax (http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Regular_Expressions)
  • Any value found by the pattern within parenthesis will be available in the "$N" syntax. The number cooresponds to the parenthesis pair count in the find expression.
  • Change the value in the second parenthesis pair to change the instance name that you want to do a replace/update for. In my example I used wall.gmt
  • The replacement expression can be translated to:
    • Insert anything found at the beginning of the line before the instance name - the stuff found by "(.*)"
    • Insert the instance name that was searched for (so you don't have to type it in the search and replace expression)
    • Give the new values to CollTarget and HATTarget
    • Append anything that was found after HATTarget

If my assumption that CollTarget and HATTarget are not always the first or in the same order, then you will need to modify the search expression into two separate search and replace calls where the first searches for only CollTarget and updates that parameter's value, then a second one to look for HATTarget and update it.