Find and replace using vi

Hello. I've searched the net for examples and in most cases, search and replace in vi goes along like s/old-text/new-text/.

I have an .sh file here and tried replacing all instances of fi with endif (only as a test) and it keeps on saying "no match found". Seems vi in FreeBSD is different from other versions of vi like those available in Linux?

Any ideas what I could be doing wrong? Thanks!

Here's the contents of my file:
Code:
                echo "Is the buildworld process complete (Y/N)?"
                read answer
                if [ "$answer" == "Y" ] || [ "$answer" == "y" ]; then

                        echo "Is the buildkernel process complete (Y/N)?"
                        read answer

                        if [ "$answer" == "Y" ] || [ "$answer" == "y" ]; then
                                echo "installing kernel"
                        fi
                fi
 
You need to add a "range" to the substitution command. If you want to search/replace the whole file use % for the range: :%s/search/replace/. Or just from line 10 to 20: :10,20s/search/replace/.
 
Back
Top