By defining a custom :command , the -range and -count allow you to better control how the range is used. However, I think that even this will not allow you to exactly duplicate the behavior of :join . The interface for Vim user commands is not as rich as it is for built-in commands.
As a workaround, you can use histget('cmd', -1) to get the command line that called your command and analyze the exact command call, including the original range (which can then be reused by passing it to another command, but execution linear arithmetic is problematic with it, since it is an unprocessed range, not the actual line numbers). The workaround will only work for interactive teams, is fragile and requires some effort. Perhaps you can avoid this problem altogether by specifying two different commands instead.
source share