How to set gvim as default text editor instead of gedit on ubuntu 11.10

By default if you want to open any files it will take gedit as default text editor.If you want to change this to gvim do the following procedure.