• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

I want to Reread a file in VI

I would like to write a script that would reread from hard disk,  a file that I AM CURRENTLY EDITING IN VI.

The problem is:  How do I get VI to easyly reread the copy of the file on the hard drive without closing the file and reopening it ?


1)   I am writing a script named "myscript".

2)   I want to insert an example of a command with the CORRECT SINTAX :)

The syntax of the if...then control structure is

   if test-command

3) Now in the VI editor session I am in I want to read off the hard disk the new file contents  so I can just  change the "test-command" and the "commands" veriable.

What I am looking for is a nice helping aid in case I get a job shell scripting and have problems with the syntax.   People look at you funny if you paste in all the examples !!!

  • 2
1 Solution
:r file
bitmechanicAuthor Commented:
with :r file I get the contents appened to the end of my file.

I now have the file twice in my file

bitmechanicAuthor Commented:
Actually I did not know that was what I wanted however it cleary was and I do not even need the script to do it.


Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now