Skip to main content
Clarifying by adding 'non-interactively', so no any questions are asked.
Source Link
kenorb
  • 18.8k
  • 19
  • 73
  • 136

I've got the following sample HTML code:

<html><body>
<table class="foo">
<tr><td>1</td></tr>
<tr><td>2</td></tr>
<tr><td>3</td></tr>
<tr><td>4</td></tr>
</table>
<table class="bar">
<tr><td>1</td></tr>
<tr><td>2</td></tr>
<tr><td>3</td></tr>
<tr><td>4</td></tr>
</table>
</body></html>

and I'd like to sort the second table in reverse.

However whenever I run this command at the beginning of the file:

:/<table class=.bar\_.\{-}\zs<tr/,/table>/sort! n /.\{-}<td/

I've got the user interactive warning saying:

Backwards range given, OK to swap (y/n)?

If I sayselect n, - nothing happens, when I sayselect y, then the results are not what I would expect.

Although it works as expected, when I run command by having cursor after the 1st table.

How I can perform the above sorting operation non-interactively without being worried where my cursor is?

I've got the following sample HTML code:

<html><body>
<table class="foo">
<tr><td>1</td></tr>
<tr><td>2</td></tr>
<tr><td>3</td></tr>
<tr><td>4</td></tr>
</table>
<table class="bar">
<tr><td>1</td></tr>
<tr><td>2</td></tr>
<tr><td>3</td></tr>
<tr><td>4</td></tr>
</table>
</body></html>

and I'd like to sort the second table in reverse.

However whenever I run this command at the beginning of the file:

:/<table class=.bar\_.\{-}\zs<tr/,/table>/sort! n /.\{-}<td/

I've got the warning saying:

Backwards range given, OK to swap (y/n)?

If I say n, nothing happens, when I say y, the results are not what I expect.

Although it works as expected, when I run command by having cursor after the 1st table.

How I can perform the above sorting operation without being worried where my cursor is?

I've got the following sample HTML code:

<html><body>
<table class="foo">
<tr><td>1</td></tr>
<tr><td>2</td></tr>
<tr><td>3</td></tr>
<tr><td>4</td></tr>
</table>
<table class="bar">
<tr><td>1</td></tr>
<tr><td>2</td></tr>
<tr><td>3</td></tr>
<tr><td>4</td></tr>
</table>
</body></html>

and I'd like to sort the second table in reverse.

However whenever I run this command at the beginning of the file:

:/<table class=.bar\_.\{-}\zs<tr/,/table>/sort! n /.\{-}<td/

I've got the user interactive warning saying:

Backwards range given, OK to swap (y/n)?

If I select n - nothing happens, when I select y, then the results are not what I would expect.

Although it works as expected, when I run command by having cursor after the 1st table.

How I can perform the above sorting operation non-interactively without being worried where my cursor is?

Source Link
kenorb
  • 18.8k
  • 19
  • 73
  • 136

How to avoid 'Backwards range given' warning when invoking search range?

I've got the following sample HTML code:

<html><body>
<table class="foo">
<tr><td>1</td></tr>
<tr><td>2</td></tr>
<tr><td>3</td></tr>
<tr><td>4</td></tr>
</table>
<table class="bar">
<tr><td>1</td></tr>
<tr><td>2</td></tr>
<tr><td>3</td></tr>
<tr><td>4</td></tr>
</table>
</body></html>

and I'd like to sort the second table in reverse.

However whenever I run this command at the beginning of the file:

:/<table class=.bar\_.\{-}\zs<tr/,/table>/sort! n /.\{-}<td/

I've got the warning saying:

Backwards range given, OK to swap (y/n)?

If I say n, nothing happens, when I say y, the results are not what I expect.

Although it works as expected, when I run command by having cursor after the 1st table.

How I can perform the above sorting operation without being worried where my cursor is?