If I have something like this <span>some<span>text</span></span>
and I want to change outermost span tag to something else, and to change both the opening and the closing tag at the same time, how can I do that with the Atom editor? I know that cmd+d shortcut selects the same text forward but in this case it will select the inner span tags also which I want to avoid.
In early Alpha there is a new package (less than 24 days old at time of edit) which seems to have the requested functionality Double Tag
-
-
2By now there is a build in way in atom: Cmd + D, D. (press D twice) This will select the next occurrence and then you'll be able to edit both at the same time. Note: this only works when you are at the starting tag with the cursor. – rambii May 31 '18 at 19:58
With ctrl + (click in text)
(or cmd + (click in text)
on Mac) you can create multiple cursors. So you can add a second one to change both tags at once.
Thats the only method I know atm.
Edit:
There is a shortcut ctrl + d
or cmd + d
which with you can mark same occurrences of the text.
There is also a package which does exactly what you want: https://github.com/dsandstrom/atom-double-tag
you can select both tags using:
Highlight the name of the opening tag Press Cmd+D to highlight the name of the closing tag Type in the replacement tag name
reagrds :)
-
Yes. And, there's no need to highlight: place the cursor at the beginning, into, or at the end of a word (any word, not just a tag name) and press Cmd+D to select the word. Continue pressing Cmd+D for selecting next instance(s) of the word. Then type to replace all of the selections with a new text. – Arta Oct 31 '16 at 1:19
-
Editing opening and closing tags together with Cmd+D do not work when there is another (opening) tag with the same name between. (e.g. an outer DIV with another DIV inside does not work). – petzi Dec 25 '18 at 19:15
Cmd+K deselects the current selection when followed by pressing Cmd+D.
So, your keyboard riff goes like this: hold Cmd and press D DK DK D.
It does not look like this is currently possible in Atom. Please refer to the following for more details:
- Discussion on the Atom forum about exactly this issue
- Issue on the bracket-matcher package with a request to add this functionality - currently still open
If you're interested, you could take a stab at adding this functionality to the bracket-matcher package...
note: in early Alpha there is a new package (less than 24 days old at time of edit) which seems to have the requested functionality Double Tag