Introduction to the installation and basic configuration of vim under Ubuntu

Source: Internet
Author: User
Tags function definition function prototype zip

Installation and basic usage

1. Log in to Ubuntu with the root account, enter vim in the command line, and get the following prompts if not installed:

The program "Vim" is already included in the following packages:

* VIM

* Vim-gnome

* Vim-tiny

* VIM-GTK

* Vim-nox

Please try:

The code is as follows:

Apt-get Install < selected packages >

Follow the prompts to enter

The code is as follows:

Apt-get Install Vim

Installation.

2. After installation, enter VIM will enter the standard mode of vim, then press the keyboard I into the insert mode, write something in it.

3. Press ESC to launch insert mode, enter standard mode, there are several basic commands to master in this mode.

: Wq Save Launch

I go into insert mode

x deletes the character of the current cursor

DD deletes the current row and saves the current row to the Clipboard

P Paste

: Help to view commands

Move the cursor up or down

4. Input: w filename to save the file to the current directory.

5.:q exits the Vim page.

6. The next time you enter VIM filename, you can edit or view this file.

Common plug-ins:

1.ctags Installation

Ctags can establish the index of the source tree, so that programmers can quickly locate functions, variables, macro definitions, etc. to view the prototype

The following is the download installation and configuration process for ctags under Ubuntu:

Download and install ctags, Terminal input command

Copy Code

The code is as follows:

sudo apt-get install Ctags

Build source index, such as I often need to check Linux kernel code, and this code in the/home/hjw951/arm/linux-2.6.12 directory

Then in the terminal into the directory, enter the command Ctags-r *, you will find a more than a tags file, this is the index file

Register the index file tags path to vim, and use the root user to enter GEDIT/ETC/VIM/VIMRC in the terminal

Add a row at the end of the open file (of course, depending on your own situation)

Set Tags=/home/user/arm/linux-2.6.12/tags

Then close the terminal and turn it back on, and you can use VIM to view the Linux function prototype anywhere

2.taglist Plugin

Presumably people who have used the source insight can remember such a function: Si can be the current file in the macro, global variables, functions, such as tag display in the symbol window, with the mouse point above the tag, jump to the position defined by the tag, you can alphabetically, the tag belongs to the class or scope, and the location where the tag appears in the file, and if you switch to another file, the symbol window updates the tag in the file.

Vim in the TagList plug-in is achieved by the above similar functions, some functions than si weak, some functions than si stronger. Moreover, the TagList plug-in is still being perfected!

To use TagList plugin, you must meet:

Open Vim's file type Automatic detection feature: filetype on

The system is loaded with exuberant ctags tool, and TagList plugin can find this tool (because taglist needs to call it to generate the tag file)

Your VIM supports system () calls

3.taglist Installation

(1) Set up in the user's home directory. Vim

The code is as follows:

[Atom@localhost ~]$ mkdir. Vim

(2) Extract Taglist_45.zip to the. Vim Catalogue

The code is as follows:

[Atom@localhost ~]$ unzip taglist_45.zip-d. Vim

The unpacked directory structure is as follows

The code is as follows:

[Atom@localhost ~]$ Ls-r taglist

TagList:

Doc Plugin

Taglist/doc:

Taglist.txt

Taglist/plugin:

Taglist.vim

(3) Installation TagList

[/code]

[Root@localhost atom]# cp/taglist/doc/taglist.txt/usr/share/vim/vim71/doc/

[Root@localhost atom]# Cp/taglist/plugin/taglist.vim/usr/share/vim/vim71/plugin/[/code]

(4) Generate Help labels

Enter Vim's doc path.

The code is as follows:

Cd/usr/share/vim/vim71/doc

Start vim, enter in command mode

: Helptags. (. Must be small to represent the current directory.) You can also start vim in any directory as long as you specify: Helptags usr/share/vim/vim71/doc/

After you generate the Help label, you can use the following command to view TagList Help

: Help Taglist.txt

Now you can try to open taglist in vim, enter the command

: Tlisttoggle to open and close the TagList window. (Commands can be abbreviated to tlist)

Introduction to command usage

CTRL +]: Jumps to the function definition where the function is called

Ctrl+t: Return to the previous lookup where the unpacked directory structure follows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.