Based on [this answer on SO](http://stackoverflow.com/questions/3498768/how-do-i-define-a-range-and-sort-by-number-in-vim-using-regular-expressions) :/^\s*-/,/^only/-1 !sort -u provided the cursor is not placed anywhere on the lines starting with `-` And, I don't know why :/^\s*-/,/^\s*[^-]/-1 !sort -u works only if cursor is positioned on the line immediately before start of search pattern