window under the use of VIM to do PHP development environment (although I have been under Ubuntu with vim).

Source: Internet
Author: User
Tags php development environment
window under the use of VIM to do PHP development environment (although I have been under Ubuntu with VIM) ...

Although Vim is essentially an editor. But with some appropriate plugins, VIM can become a full-featured IDE. I have been using vim for a long time, after repeated experiments, configuration of an efficient PHP development environment, Real home travel, murder, kill anyone necessary good products.

Install Vim
Since most readers use the Windows environment, this article uses Windows as the operating environment. However, due to the excellent cross-platform features of vim, configuration files can be used in the Linux version of Vim with simple modifications.

Currently the latest version of Vim is 7.2, if there is no specific reason to recommend installing the latest version.

Download Address:
Download file: Ftp://

Do not install in a directory with spaces, Chinese, and others remain the default. The author's installation directory is C:appsofficevim, after the text is also subject to this. For the convenience of narration, the author uses $vim to represent the installation directory of Vim. For example, if your vim is installed in D:vim, the $vim represents D:vim.

Start configuring VIM
Our configuration of vim is divided into several steps.

Automatically takes effect after modifying _VIMRC
Open the $vim directory, you can see that there is a _VIMRC file, with vim open this file, delete all content, after the last insert two lines:

"AutoLoad _VIMRC

autocmd! Bufwritepost _VIMRC Source%

The above command allows us to automatically load the _VIMRC file when we edit the _VIMRC file and save it via vim, so that our customization of Vim can take effect immediately (no need to restart vim).

The culture in Vim
Add the following text to the top of the _VIMRC:

"Disable VI ' s compatible mode.

Set nocompatible

The Set Encoding=utf-8

Set Fileencodings=ucs-bom,utf-8,gbk,default,latin1

"Use Chinese help


The function of the above code is to disable the VI compatibility mode (the original VI features too little, no need to consider compatibility), according to Utf-8, GBK order to detect the file encoding, and set the Help for Chinese. But setting set HELPLANG=CN does not immediately see the Chinese help, we also have to download the Chinese help file.

Download Address:
Download file: vimcdoc-1.6.0.tar.gz

After the Chinese help file is compressed, all files from the Doc subdirectory in the package are copied to the $vimvimfilesdoc directory. At this point, enter: Help command can be seen in Chinese.

Chinese Help or 7.1 version, but does not affect our use.

Set font
Select "Edit", "Select Font" from the Vim menu to specify the font you prefer for vim. I use the Consolas font, the size is set to 9pt. This setting shows that the code is very beautiful, but Chinese is a little distorted.

When set, enter the command: Set Guifont can view the current font settings and write the settings to the _VIMRC file.

The Set GUI options

If has ("gui_running")

Set Guifont=consolas:h9


The If ... endif in the above code is a conditional judgment structure. Indicates that the font is only set when we use the graphical interface version of Vim.

Basic setup for editing PHP code
Now open with Vim. php files appear to be difficult to read, don't say code highlighting, even line numbers are not displayed. So add the following to _VIMRC:

"Enable Syntax Highlight

Syntax enable

"Show line number

Set Nu

"Show matching Bracets

Set Showmatch

"Basic Editing options

Set Expandtab

Set shiftwidth=2

Au FileType html,python,vim,javascript setl shiftwidth=2

Au FileType html,python,vim,javascript setl tabstop=2

Au FileType java,php setl shiftwidth=4

Au FileType java,php setl tabstop=4

Set Smarttab


Set tw=0

"Auto Indent

Set AI

"Smart Indet

Set Si

"C-style indeting

Set Cindent

"Wrap Lines

Set Wrap

The above settings enable editing features such as formatting highlighting, line number display, and bracket matching, automatic indentation, and the ideal editing experience for most situations. However, the support for. php files is not perfect at this time, you need to download a special PHP plugin.

Download Address:
Download file: php.tar.gz

Copy the Php.vim into the $vimvimfilessyntax directory.

Set your favorite color scheme
The default color scheme is believed that few people will like, you can see the color scheme and download (there are hundreds of) through the following URL.

Download URL:

This URL lists more than 300 color schemes and the actual display results, click on the scheme name to download to a. vim file. Put the file in the $vimvimfilescolors directory, and then add it in _VIMRC:

The Set color schema

ColorScheme Oceandeep

These two lines of code need to be added to the IF has ("gui_running") ... endif code block, for example:

If has ("gui_running")

Set Guifont=consolas:h9

The Set color schema

ColorScheme Oceandeep


After setting the display effect is more beautiful:-)?

More useful editing settings
Although not specifically for editing. php file settings, these options can make vim better, so it is recommended to add:

"Sets how many lines of the history VIM Har to Remember

Set history=400

"Set to auto read when a file was changed from the outside

Set Autoread

"The mouse enabled all the time:

Set Mouse=a

"Do not redraw, when running macros. Lazyredraw

Set LZ

"Set 7 lines to the Curors–when moving vertical.

Set so=7

"The CommandBar is 2 high

Set cmdheight=2

"Change buffer–without saving


"Ignore Case when searching

The Set ignorecase

Set Incsearch

"Set Magic on

Set Magic

"No Sound on Errors."

Set Noerrorbells

Set Novisualbell

Set t_vb=

"How many tenths of a second to blink

Set mat=4

"Highlight Search Things

Set Hlsearch

"Turn Backup off

Set Nobackup


Set Noswapfile

"Smart backspace

Set Backspace=start,indent,eol

"Switch buffers with Tab



After some modification, our vim has been able to easily edit the. php file. But there is still much work to be done to build the PHP development environment.


The left side of the IDE is directory navigation, the middle is the editing area, and the right side is a list of methods for quick jumps in files that are already open. Pressing the CTRL+X key in the editing area also displays a list of files that have been opened.

Other features, such as auto-completion, code templates, and more. Having seen the beautiful, we will step by step to build the PHP IDE.

Implementing directory Navigation with Nerdtree
It is normal to edit multiple files at the same time while developing PHP applications. So there must be a handy directory navigation tool to quickly switch between directory structures to find files that need to be edited.

VIM provides this kind of function plug-in many, more well-known have project, Winmanager and so on. But I personally think the best use is still the NERD tree this plugin. Nerdtree can not only display the full directory tree structure, but also set any directory as the root directory. and provides the bookmark function of the directory navigation, it is very convenient.

Download Address:
Download file:

Extract the directory structure in the package to the $vimvimfiles directory. When you are finished, you should find the $vimvimfilesdocnerd_tree.txt file and the $vimvimfilespluginnerd_tree.vim file separately. Then enter the command in VIM: Helptags $VIMvimfilesdoc, add Nerdtree's help document to Vim.

Finally, add the following in _VIMRC:



After you restart Vim, you can see a directory tree on the left by pressing the F10 key. Click the button in the Catalog tree window to view detailed help information.

The most common operating keys are:



C (uppercase C key)

Set the directory where the cursor is located as the root directory

U (lowercase u key)

Go to the top level directory

O (lowercase o key, not "0")

Expands (or collapses) the subdirectory of the directory where the cursor is located. If the cursor is located in a file, open the file in the edit window

Also enter the table of contents in the Catalog tree window: Bookmark name You can also add the directory where the cursor is located in the Favorites folder. Next use: The Bookmarktoroot collection name can go directly to the directory, and the directory is the root directory. More commands can refer to Nerdtree's help documentation.

Implementing code Navigation with TagList
Solve the directory and file navigation problems, we also want to provide a means for jumping between the code, TagList is such a plug-in. TagList can list classes, functions, constants, and even variables that are defined in open files.

Download Address:
Download file:

The compressed package needs to be fully decompressed to the $vimvimfiles directory, with: helptags $VIMvimfilesdoc the command index taglist the plugin's help document. TagList plug-ins need to rely on ctags programs to work. The Ctags version currently used is exuberant Ctags.

Download Address:
Download file:

You only need to copy the Ctags.exe in the package to the $vimvim72 directory. Ctags.exe should be in a directory with Gvim.exe.

Finally add the following in _VIMRC, set up the TagList plugin:


"= Plugin Configuration



Let Tlist_auto_highlight_tag = 1

Let Tlist_auto_open = 1

Let Tlist_auto_update = 1

Let Tlist_close_on_select = 0

Let Tlist_compact_format = 0

Let Tlist_display_prototype = 0

Let Tlist_display_tag_scope = 1

Let Tlist_enable_fold_column = 0

Let Tlist_exit_onlywindow = 0

Let Tlist_file_fold_auto_close = 0

Let Tlist_gainfocus_on_toggleopen = 1

Let Tlist_hightlight_tag_on_bufenter = 1

Let Tlist_inc_winwidth = 0

Let Tlist_max_submenu_items = 1

Let Tlist_max_tag_length = 30

Let Tlist_process_file_always = 0

Let Tlist_show_menu = 0

Let Tlist_show_one_file = 0

Let Tlist_sort_type = "order"

Let Tlist_use_horiz_window = 0

Let Tlist_use_right_window = 1

Let Tlist_winwidth = 40

Let tlist_php_settings = ' php;c:class;i:interfaces;d:constant;f:function '

The setting here is the author's personal habits of the settings, we are familiar with the taglist of the specific settings can be tried first.

After Setup is complete, edit the. php


  • 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: 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.