Final answer:
To add a comma to every line in vi that doesn't end with a question mark, use this command: ':g/[^?]$/s/$/,', which applies a global substitution on lines matching a specific pattern.
Step-by-step explanation:
To write a vi substitution command that will add a comma to every line that doesn't end with a question mark, you can use the following command:
:g/[^?]$/s/$/,
This command breaks down as follows:
- :g is the global command that tells vi to execute a command on all lines that match a given pattern.
- [^?]$ is the pattern that matches lines that do not end with a question mark. Here, [^?] means any character except the question mark, and $ denotes the end of the line.
- /s/$/, is the substitution command, where $ matches the end of the line and replaces it with a comma.
By running this command in vi, you add a comma to the end of each line that does not already conclude with a question mark.