So Lets say I have a list\Summit\SummitSign\sun\ProgrammingOnABoat\SunCloud\SunshineOpenCircled\sup\supdsub\supdsub\supedot\suphsol\suphsub\Summit\SummitSign\sun\Summit\boatProgramming\supI do not want to sort the list, I just want to remove identical rows, leaving only the first, like so:\Summit\SummitSign\sun\ProgrammingOnABoat\SunCloud\SunshineOpenCircled\sup\supdsub\supedot\suphsol\suphsub\boatProgrammingor like so:\Summit\SummitSign\sun\ProgrammingOnABoat\SunCloud\SunshineOpenCircled\sup\supdsub\supedot\suphsol\suphsub\boatProgrammingAs you can see, it was not sorted, but the latter entries were removed.
In Vim, how can you delete following identical rows in a visual selection, without sorting?
ex mode;replace;sort
If you don't care about removing the first occurrence (leaving the last one), you can use the following global command:g/^\(.*\)\n\_.*\(^\1$\)/dDecomposing:g/                     /d    the global command will delete matched lines  ^\(.*\)                    Match anything from start of the line (create a group)         \n                  Match the end of the line           \_.*              Match any character (with new line) 0 or more time               \(^\1$\)      Match the previously matched groupThis will find any line that has a duplicate later in the file and delete it.It will delete duplicate lines but keeping only the last one.As a workaround for the seek of keeping only the first occurence, you can use g/^/move 0Before and after the substitution, this will reverse the order of the file, thus keeping the first line.