Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following lines in my document :

[Ctrl + r] : ..............
[Ctrl + u] : ..............
...
[Ctrl + m] : ..............

What I want (using TeXworks replacement wizard) is to replace all the string matching the pattern [*] by \mycommand{$1} so the lines becomes :

\mycommand{Ctrl + r} : ..............
\mycommand{Ctrl + u} : ..............
...
\mycommand{Ctrl + m} : ..............

How should I proceed ?

share|improve this question
    
Use emacs, it has a replace-regexp command. –  Alex Feb 24 '13 at 12:49
    
@cgnieder not if i replace only the selection –  Oddant Feb 24 '13 at 13:39
add comment

1 Answer 1

up vote 4 down vote accepted

TeXworks can replace regular expressions. Use Search->Replace from the menu (or Ctrl+R), then put \[Ctrl ([^]]*)\] in the "Replace" field and \mycommand{Ctrl \1} in the "With" field, and in addition activate the "Regular expression" checkbox.

Pressing "Replace" or "Replace all" will give the desired result.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.