-1

Can anyone explain the various ways of doing external command like :! :%! and how to put them at the end of a file? I understand that :X puts them after line X, but :G does not appear to put them at the end of the file.

I guess I could always run the command and append it to the file from the command line command >> % but would this immediately show up in vim? Is there a better way?

I always reading that Vim can be used as a hex editor but if you don't edit in binary it may break the file...why?

closed as unclear what you're asking by Heptite, Kevin Panko, Breakthrough, Tog, Excellll Jun 20 '14 at 16:11

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    If you have multiple questions to ask, ask multiple questions. – romainl Jun 19 '14 at 6:53
2

[count]G is a normal mode command used to move he cursor to line [count], defaulting to the last line if no [count] is given. You can't use it as a range for an Ex command.

In a range, the shortcut for "last line" is $.

The difference between :!command and :{range}!command is that the former executes command in a subshell without passing anything to the command via stdin while the latter passes the {range} to command via stdin and replaces it with the output of command. It is called a filter and you can read all about it in :help filter.

Since you don't seem to want to filter the content of your buffer, the right pattern for simply reading the output of command would be :!command.

:read is the right command to use if you want to insert the output of an external command in the current buffer.

Use this command to insert the output of external command command below the current line:

:r!command

Use this command to insert the output of external command command below line 15:

:15r!command

Use this command to insert the output of external command command below the next "foo":

:/foo/r!command

Use this command to append the output of external command command to the current buffer:

:$r!command

Use this one to prepend the output of external command command to the current buffer:

:0r!command

See :help :read! and :help range.

Not the answer you're looking for? Browse other questions tagged or ask your own question.