Who said Vim is not an IDE? (2)

Source: Internet
Author: User
ArticleDirectory
    • (1) vimrc Introduction
    • (2). Vim folder
Environment Configuration

"If you think Vim is just a text editor, you lose"-from Vim

Vim provides a variety of configuration functions in a simple way. The main configuration system consists of a file and a folder. On an OS X/Linux/Unix machine installed with vim, go to the user's home directory and find the. vimrc file and. Vim folder. This is all the configurations of vim.

(1) vimrc Introduction

The. vimrc file in the user directory is the main configuration file of VIM for the current user. This file is not necessary. If it is not available, create it. The file is located in the current user's home directory. You can use~ /. VimrcFind. Each command in the file is automatically run when Vim is started.
Through. vimrc, We can customize the configurations for VIM, including usage, display style, writing functions, and running plug-ins. All the commands in vimrc can be run through a similar: Comm ARGs [= args1]And takes effect immediately.
The following is a. vimrc sample script, which contains some common configurations. The comments below are a brief description.

The comments of vimrc are represented by double quotation marks ("). The braces in the example only represent the functional area. They are part of the comments and have no other meanings.
. Vimrc has rich configurations and can define various macros, functions, ins and ing. I have seen more than 1000 rows of. vimrc configuration at the longest time. The example here is relatively simple and suitable for entry-level users.

SYN on "  Syntax support  "  Common conf {general configuration Set AI "  Auto indent Set BS = 2                      "  Delete with the return key in insert mode Set showmatch "  CodeMatch Set laststatus = 2              "  Always show status line Set expandtab "  Use the following three configurations to set the number of tabs and indentations Set shiftwidth = 4  Set tabstop = 4  Set cursorline  "  Underline the row where the cursor is located Set number "  Show row number Set autoread"  The file has been modified outside vim and is automatically re-read.  Set ignorecase  "  Case Insensitive during retrieval Set fileencodings = UFT- 8 , GBK "  Use UTF-8 or GBK to open a file Set HLS "  Highlight matching items during retrieval Set helplang = Cn "  Help set the system to Chinese Set foldmethod = syntax "  Code folding "  }}  "  Conf for tabs, used to configure the tab by pressing ctrl h/  L switch tags, etc.Let mapleader = '  ,  '  Nnoremap <C-l> Gtnnoremap <C-h> Gtnnoremap <Leader> T: tabe <CR> "  Conf for plugins {plug-in-related configuration  " Status Bar Configuration  "  Powerline { Set guifont = powerlinesymbols \ For  \ Powerlineset nocompatibleset t_co = 256  Let G: powerline_symbols = '  Fancy  '  "  }  "  Pathogen is a plug-in used by VIM to manage plug-ins.  " Pathogen {  Call pathogen # infect ()  "  }  "  }} 

 

(2). Vim folder

. Vim is the main configuration folder of VIM, which is located in the main directory of the current user. You can useCd ~ /. VimEnter. This folder is generally used to place plug-ins and related help documents. Common directory structures include:

 
Doc // help document directory autoload // plug-in directory automatically loaded when Vim is started. The plug-in directory is plugin //.

Of course, if you have installed enough plug-ins, there will be a wide variety of plug-ins in this directory, and folders such as syntax, snippets, and indent will pop up. Files contained by a plug-in are often distributed in Multiple folders, which is difficult to manage. We will introduce a plug-in for managing plug-ins later, so that the directory is clean, tidy, and easy to manage, the plug-in name isPathogen!

Enter the command in VIM: HelpTo go to the Help page. The default is English help. If you prefer to read Chinese, you can install Chinese help in the following ways:

    1. Download the compressed Chinese help file package
    2. Decompress the file and copy the file in the doc directory ~ /. Vim/doc
    3. Are you sure you have set in. vimrcSet helplang = Cn
    4. Enter the command: HelpYou can enter the Chinese help
Basic Concepts

Below we will introduce several basic concepts in VIM: buffer, window, and tab-page.

    1. Buffer: All files opened with vim are loaded into the memory, in the memory, buffer is used to describe the edited file. A buffer corresponds to a copy of the edited file. After editing a buffer, we can save the file. The buffer not only contains the file content, but also records the configuration information such as the editing status of the file, such as activation, hiding, and the number of Last edited rows. For details, refer to the help documentation.
      you can use Vim to open multiple files and edit them at the same time. You can also disable unnecessary files, however, the file copies are still stored in the buffer zone. You can view these buffers through : ls or : buffers , you can also re-open the file by using a method similar to : Buffer n (N indicates the serial number of the buffer ). Of course, we have a better way to deal with these buffers, that is, commandtbuffer. To use commandtbuffer, first install the commandt plug-in, please remember the name of this plug-in. We will introduce it later.
    2. window: A display window corresponding to the buffer. A buffer can correspond to multiple windows. For example, you can use : Split filename or : the vsplit filename command opens a file in multiple windows. When the file in a window is modified, the files in other windows are updated synchronously. Of course, we can open multiple files in multiple windows and save and exit with : WQ after editing. But remember, as long as the vim process is not finally exited, the opened file buffer is still stored in the cache and can be opened again at any time.
    3. tab-page: tab-page is easy to understand. corresponding to a group of windows, we can use ': tabedit filename 'opens a file on another tab. Multiple windows can be opened on this tab.

You can clearly express the relationship between buffer, window, and tab-page:

Understanding the relationship between the three concepts and the three is of great help for us to make good use of vim.

To be continued, the next article is the vim plug-in ......

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.