Monday, March 4, 2013

Gvim FAQ


  • How to search number in gvim file??
    If any text file contain digits it is in the range 0-9 We can use simple gvim command to find all digits in gvim edited file. As follows
                      /s/[0-9]
  • How to revert/undo action based on time?
    Gvim provides facility to revert your changes based on time this can be achieved by the following command??
            :earlier 50m           or            :earlier 5h
    using this command you can revert back to 50 min or 5 hours. This will be very much useful if you have done all things wrong for the day.
  • How to delete line containing  particular string?
    Sometimes while debugging you find that some lines in log is unnecessary and obstacle in your debugging. This can be solved by the following command.
               :g/gvim_line_to_delete/d 
    Command deletes all lines containing string gvim_line_to_delete
    some time you might want particular lines and delete all other. This can be achieved by the following command.
                :v/gvim_line_to_keep/d
    Command deletes all line which does not contain gvim_line_to_keep.
  • How to jump at particular line directly?
    when you compile a code first time after writting always there is a compilation error.(Whenever I do not get error I doubt myself) compiler shows you the line number at which error is. If you have written code of 3000 line you will get tired by scrolling. But in gvim you can directly go to particular line by the following command.
               :gvim_line_num
    thus if you want to go to 245 th line simply write command :245 and your cursor is moved to that line. As we have seen $ indicates end of something. :$ command moves your cursor at last line of your file. 

                                                       GO BACK TO INDEX

No comments:

Post a Comment