2
For example I have file consisting of structures like
name = {
foo = bar;
...
};
So in file there are lots of structures like this.
How can I sort them (I'm using vim
but emacs
is surely ok too) by name? But having their fields unmodified?
I mean
b = {
bfoo = bar;
...
};
a = {
afoo = bar;
...
};
Goes to
a = {
afoo = bar;
...
};
b = {
bfoo = bar;
...
};
Update Structures may also contain same structures.
b = {
c = {
cfoo = bar;
...
};
...
};
Please, check an update. – JagaJaga – 2014-11-19T18:59:37.807
@JagJaga - if the indentation of the root element is fixed, you can alter the search to something like
:g/\v^\w \= \{/.,/\v^\};/;/join!
. The\v
sets very magic so you can use^
in a search to indicate the start of a line (but now you have to escape the =, { and } characters) – Lieven Keersmaekers – 2014-11-20T06:31:29.803