Configuration and use of vim editor.

vim configuration and simple usage.

The source link address used to install vim and tags: http://blog.csdn.net/shaohuazuo/article/details/46745209 Blog

The vimrc configuration file can refer to the following address: http://blog.csdn.net/shaohuazuo/article/details/41721647 Blog


1. Enter the command line mode.

    You can press the esc key to enter.

2. Move the cursor command in vim. Switch to the command line:

    (h left, j down, up k, right l)
    h: move one character to the left, l: move one character to the right. j: move down one line. k: move up one line.

3. From edit mode to insert mode. You can use,i,o,a and I,O,A

    (o, O, iI, aA)
    The row where the cursor is located 
    o: insert at the next line, insert at the previous line at O
    ​​i: insert at the current position. I: Insert at the beginning of the current line
    a: Insert at the next position of the current character where the cursor is located, A locates at the end of the line where the current cursor is located

4. Delete.

   db,x: db delete a word in reverse, x deletes the character at the cursor position. Delete in reverse.
   b,dw: b: back to the beginning of the word. dw: delete the word.
   daw: daw: the cursor needs to stay At the end of the deleted word. daw: Delete all characters and spaces from this word to the previous word.

5. Select area

   vbo: The cursor position is at the end. This is to highlight and select a word with vbo.
   veo: The cursor position is at the head of the word. You can use veo to select words.

   If you need to select multiple lines, you can use v, and use jk to move up and down Select the line.
   You can also select by block mode. ctrl+v,

6. Let's combine parts 3 and 5 to see the insert.mode.

   1. Insert a word This in the line number of the selected line, you can do this, use ctrl+v in the command line mode, go to the block visual mode, use jk to move up and down, select the corresponding line. 2. Press I. Insert
   This , and then press esc for a few ok.
   3. Insert at the end of each line, you can use ctrl+v to enter the block selection mode, use jk to select the line up and down, and then press $. Then expand the selection to the end of the line. Press A. Insert at the end of the line. After inserting the word, press esc and it will be ok.

7. replace

  : s/vivian/sky/ Replace the first vivian in the current line with sky
  : s/vivian/sky/g Replace all vivians in the current line with sky
  : n, $s/vivian/sky/ Replace the nth line to the last line The first vivian in each line is sky
  : n, $s/vivian/sky/g Replace all vivians in each line from the nth line to the last line as sky:
    s#/#\ Replace all / in the current line with this \ . If the replacement is /all do not use / as a separator.

8. Find c syntax errors.

   1. vim.
   2. copen.
   3. vsp ac
   4. make ./a
   5. If there is a syntax error, you can delete it directly.

9. Install vim + ctags.

   1.sudo apt-get install vim .

   2.sudo apt-get install ctags.

   3. Configure the vim editor file as follows, replace /etc/vim/vimrc with the file that needs to be configured as follows.

   4. Use it in the source code directory file that needs to be viewed. The ctags -R command generates a ctag file.
   5. Set the path of the ctags file directory in the vimrc configuration file.
   6. vim /etc/vim/vimrc
   7. Add the following as .set tag+=/home/zshh/work/arm/exynos4412_lzy1/src/linux/linux-3.5/tags The configuration is complete. 8. The following is a simple use. vim -t
   memset
      //Directly open the definition of a representation. It is possible There are multiple.
      vim ac //Switch to the command line.
      Use the ta command to find a definition.

      Use the tselect command to see in which files the indicator is defined.

Author: Zuo Shaohua

Blog address: http://blog.csdn.net/shaohuazuo/article/details/46959581

Please indicate the source.

Guess you like

Origin blog.csdn.net/shaohuazuo/article/details/46959581