Without leaving vi, we can run shell commands from within vi.
e.g. we need to insert contents of a file within our current file opened in vi.
1) Insert will begin immediately after the cursor. So we place cursor where we need the insert.
2) enter vi command mode
3) :r! cat filename
:r! can be used to insert output of a unix command also.
e.g. :r! ls
the above command inserts list of the files in the current directory (pwd)
:sh can be used to enter shell from within vi.
to return to vi, use exit.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment