vi +'%!sort | uniq' +wq file.txt
We open a file with vi and run two vi commands (specified with +):
%!sort | uniq% = range definition, it means all the lines in the current buffer. ! = run filter for the range specified. Filter is an external program, in this example sort | uniqwq = write buffer contents to file and exit.