"Turn" who says Vim is not an IDE? Two

Source: Internet
Author: User

Environment configuration

"If you think Vim is just a text editor, you Lose"--from the VIM veteran

VIM provides a rich set of configuration features in a concise manner, and the main configuration system consists of a file and a folder. On a vim-installed OS X/linux/unix machine, enter the user's home directory to find the. vimrc file and the. Vim folder, which is all the configuration information for vim.

(1). VIMRC Introduction

The. vimrc file in the user directory is the main profile of vim for the current user, which is not required and is created without it. The file is located in the current user's home directory and can be ~/.vimrc found, and when Vim starts, it automatically runs each command in the file.
Through. VIMRC we can personalize vim for use, display style, write functions and run plug-ins, and so on. All commands in the VIMRC can be run dynamically in a similar way during Vim runtime :comm args[=args1] and take effect immediately.
Here is a. VIMRC sample script that contains some common configurations, followed by a brief description.

The comments of the. VIMRC are denoted by double quotation marks ("), and the braces in the sample represent only the Ribbon, which is part of the comment and has no other meaning
The configuration of the. VIMRC is very rich, you can define a variety of macros, functions, plugins and mappings, I have seen the longest. VIMRC configuration has more than 1000 lines, here The example is relatively simple, suitable for entry-level users

 syn on "syntax supports" common conf {{Universal configuration set AI "auto indent set bs=2               "Delete set Showmatch with backspace key in insert mode" code match set laststatus=2 "Always show status line set Expandtab "The following three configurations work together, set the tab and indent spaces set Shiftwidth=4set tabstop=4set cursorline" to underline the line where the cursor is set number " The line number set Autoread "file was modified outside of vim, automatically re-read into set ignorecase" when retrieving ignore case set FILEENCODINGS=UFT-8,GBK "using utf- 8 or GBK Open file set HLS "highlight match when retrieving set HELPLANG=CN" Help system set to Chinese set foldmethod=syntax "code Folding"}} "Conf for tabs, Configuring for tab pages, switching tabs by Ctrl h/l, etc. let Mapleader = ', ' nnoremap <C-l> gtnnoremap <C-h> gtnnoremap <lea der>t:tabe<cr> "conf for plugins {{plugin-related configuration" status bar Configuration "Powerline{set guifont=powerlinesymbols\ for\ powerlineset N Ocompatibleset t_co=256let g:powerline_symbols = ' Fancy ' "}" pathogen is a plugin used by Vim to manage Plugins "Pathogen{call Pathogen#infect ()"} " }}

(2). Vim folder

Vim is the master Configuration folder for Vim, which is located in the current user's home directory and can be cd ~/.vim accessed. This folder is typically used to place plug-ins and related help documents, and the common directory structure includes:

doc                           //帮助文档目录autoload                      //Vim启动时自动加载的插件目录plugin                        //插件目录,一般在使用Vim时通过命令呼出

Of course, if you have enough plug-ins installed, the directory will become a lot more, syntax, snippets, indent and other folders will pop up. A plug-in contains files are often distributed in a number of folders, management is more troublesome, later we will introduce a management plugin plug-in, so that the directory becomes clean and tidy, easy to manage, the name of the plugin is pathogen!

Enter the command in VIM to enter the :help help page, the default is English help, if you like to see Chinese, you can install the Chinese Help content in the following ways:

    1. Download the Chinese Help file compression package
    2. Unzip, copy the files under the doc directory to ~/.vim/doc
    3. Confirm that the VIMRC is set in the.set helplang=cn
    4. Enter the command to :help enter Chinese help
Basic concepts

Let's take a look at some of the basic concepts of vim: Buffer, window, and Tab-page.

    1. Buffer: Files opened with VIM will be loaded into memory, in memory we use buffer to describe the edited file, a buffer corresponding to a copy of the edited file. When we have finished editing a buffer, we can save the file. Buffer not only contains the contents of the file, but also records the configuration information such as the editing status of the file, such as activation, hiding, last edited line number, etc., can consult the help document.
      With Vim you can open multiple files at the same time to edit, you can also turn off the unwanted files, but then the copy of the file is still stored in the buffer, we can pass :ls or :buffers view these buffers, you can also :buffer n reopen the file in a similar way (n indicates the serial number of buffer). Of course, we have a better way to deal with these buffer, that is commandtbuffer, to use Commandtbuffer, first to install the Commandt plug-in, please remember the name of this plugin, introduced later.
    2. window: is a display window corresponding to buffer. A buffer can correspond to multiple windows, for example, we can :split filename :vsplit filename open a file in multiple Windows through or command, and when the file of one window is modified, the other windows will be updated synchronously. Of course, we can open more than one file in multiple windows, edit and :wq exit with Save, but remember, as long as not finally quit the vim process, then the open file buffer is still stored in the buffer, can be opened again at any time.
    3. Tab-page:tab-page is easier to understand, and for a set of Windows, we can open a file in another tab with ': Tabedit filename ', and open multiple windows in this tab.

The relationship between buffer, window, and tab-page can be clearly expressed:

Understanding these three concepts and the relationship between the three, for our good use of vim is very helpful.

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

"Go" who says Vim is not an IDE? (ii)

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.