Saturday, March 2, 2013

Gvim basics-2

In this page I have tried to cover selection of text, copying, delete, paste and searching some keyword  using gvim text editor. And all this functions is done without touching mouse.

  • Selecting the text in gvim 
    There are main three methods that I know using which you can select some text in you gvim file. There might be so many other methods. 1) First is go to the character place from where you want to select text in the gvim file. Then press v and now by moving your cursor up,down,left or right from keyboard you can select text. 2) In second type of selection go to the line which you want to select then press shift + v and then by pressing up or down arrow in your keyboard you can select lines which you want to process. 3) The third method is control + V  now by moving your arrow up or down you can select your text in gvim editor file.
    All three methods seem same but you will find and advantage of using each methods once you will start using it.
  • Copying text in gvim/vim
    You can copy text using y command once have selected your desired text. Here y indicates action yank. Simply google yank and you will find it why they have chosen y for copying. It is also possible to copy some lines even if you have not selected any line in gvim editor. This command is yy
    You can copy the line at which cursor is by simply pressing command yy. Or you also can specify how many lines you want to copy without selecting those lines and then press yy . Suppose you want to copy your current line and 7 lines below current line. Do not need to first select those lines and than copy it. You can directly select those 8 line by pressing first 8 and next to it yy .
    Once you have copied text in clipboard you have to just press p in command mode and it is done for peasting it.
  • Deleting or cuting text in gvim/vim
    Deleting some text from file edited in gvim is as simple as copying. First select your text in gvim editor you want to delete. Then press d  in command line and it is done. One thing you should keep in mind is that while you are deleting some text it stores in gvim's clipboard so if you want to pest it some where else you can do it.
    Same as copying you can delete current line at which your cursor is can be deleted by pressing dd and current line is deleted  or I can say that line is completely removed form your gvim editor text. If you want to delete say 10 lines you can simply press 10 and press dd  same as copying 10 lines.
    As I said text we are deleting remain stored into the clipboard of gvim till next delete or copy operation is performed so you can paste any where you want.

  • Searching keyword in file edited in gvim/vim
    Searching specific key word in gvim is very much easy task to do. You need to be in command mode by pressing Esc. And after that type " / "  and then type your keyword you want to search. Suppose you want to search keyword "gvim" in the file that you are editing. For this type the following command in your command line.
                /gvim
    and press Enter and your cursor will move to the matched keyword. You can go to next matching keyword by pressing n .  If you want to search forward in the file press n  and if you want to search backward in the file press N . Another way for searching keyword is move your cursor to the keyword and press *(as-trick) you can find another similar word. currently you might not find advantage in searching forward or backward but it is very much useful while you are editing large program code that might contain 2000 lines.
Up till now we have seen the commands that will replace your habit of using notepad or any other GUI editor. You will also see how much it is easy and fast to use gvim for editing files. In next link we will see some more features of gvim. (or I can say more reasons to use it)
          http://gvimeditor.blogspot.in/2013/03/gvim-basics-3.html

No comments:

Post a Comment