In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you the "build Vim for custom PHP development tools what are the skills", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "build Vim for custom PHP development tools what are the skills" this article.
Install vim
Since most readers use the Windows environment, this article uses Windows as the running environment. However, due to the excellent cross-platform nature of vim, the configuration file can be used in the Linux version of vim with simple modifications.
At present, the latest version of vim is 7.2. if there is no special reason, it is recommended to install the latest version.
Download address: http://www.vim.org/download.php#pc
Download file: ftp://ftp.vim.org/pub/vim/pc/gvim72.exe
Do not install it into a Chinese directory with spaces during installation, and keep the rest by default. The author's installation directory is c:/apps/office/vim, which will prevail later. For ease of description, the author uses $VIM to represent the installation directory of vim. For example, if your vim is installed in d:/vim/, then $VIM represents d:/vim/.
Start configuring vim
Our configuration of vim is divided into several steps.
The modification of _ vimrc takes effect automatically.
Open the $VIM directory and you can see that there is a _ vimrc file in it. Open this file with vim, delete everything, and insert two lines at the end:
"autoload _ vimrcautocmd! bufwritepost _ vimrc source%
The above command allows us to automatically load the _ vimrc file when we edit the _ vimrc file through vim and save it, so that our customization of vim can take effect immediately (no need to restart vim).
Make vim Chinese culture
Add the following text to the top of _ vimrc:
"disable VI's compatible mode..set nocompatible" set encoding=utf-8set fileencodings=ucs-bom,utf-8,gbk,default,latin1 "use chinese helpset helplang=cn"
The purpose of the above code is to disable vi compatibility mode (the original vi features are too few to consider compatibility), detect file encodings in the order of utf-8 and gbk, and set the help to Chinese. However, setting set helplang=cn can not immediately see the Chinese help, we also have to download the Chinese help file.
Download address: http://vimcdoc.sourceforge.net/
Download file: vimcdoc-1.6.0.tar.gz
After you get the Chinese help file package, copy all the files in the doc subdirectory of the package to the $VIM/vimfiles/doc directory. Enter the: help command at this point and you can see the Chinese help.
Chinese help is still version 7.1, but it does not affect our use.
Set font
Choose "Edit"-> "Select Font" on the vim menu, and you can specify the display font you like for vim. The author uses the Consolas font and the size is set to 9pt. This setting shows that the code is very beautiful, but the Chinese is a little out of shape.
Once set, enter the command: set guifont can view the current font setting and write it to the _ vimrc file.
"set gui optionsif has (" gui_running ") set guifont=Consolas:h9endif
The if in the above code... Endif is a conditional judgment structure. Indicates that fonts are set only if we use the graphical interface version of vim.
Make basic settings for editing PHP code
Opening a .php file with vim now looks ugly, not to mention the code is highlighted, and the line number is not even displayed. So add the following to _ vimrc:
"Enable syntax highlightsyntax enable" Show line numberset nu "show matching bracetsset showmatch" Basic editing optionsset expandtabset shiftwidth=2au FileType html,python,vim,javascript setl shiftwidth=2au FileType html,python,vim,javascript setl tabstop=2au FileType java,php setl shiftwidth=4au FileType java,php setl tabstop=4 set smarttabset lbrset tw=0 "Auto indentset ai" Smart indetset si "C-style indetingset cindent" Wrap linesset wrap
The above settings enable formatting highlighting, line number display, as well as parenthesis matching, automatic indentation and other editing functions, for most cases can get the ideal editing experience. However, at this time, the support for .php files is not perfect, so you need to download a special php plug-in.
Download address: http://www.vim.org/scripts/script.php?script_id=1571
Download file: php.tar.gz
Just copy the php.vim into the $VIM/vimfiles/syntax directory.
Set up your favorite color scheme
I believe that few people will like the default color scheme. You can check out the color scheme and download it at the following URL (there are hundreds of them).
Download URL: http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/index-c.html
This web site lists more than 300 color schemes and the actual display effect. Click on the name of the scheme to download to a .vim file. Place the file in the $VIM/vimfiles/colors directory and add to _ vimrc:
"set color schemacolorscheme oceandeep
These two lines of code need to be added to if has ("gui_running"). In the endif code block, for example:
If has ("gui_running") set guifont=Consolas:h9 "set color schema colorscheme oceandeependif
After setting, the display effect is much more beautiful: -)
More useful editing settings
Although not specifically for editing .php files, these options can make vim easier to use, so it is recommended to add:
Sets how many lines of history VIM har to rememberset history=400 "Set to autoread when a file is changed from the outsideset autoread" Have the mouse enabled all the time:set mouse=a "Do not redraw, when running macros.. Lazyredrawset lz "set 7 lines to the curors-when moving vertical..set so=7" The commandbar is 2 highset cmdheight=2 "Change buffer-without savingset hid" Ignore case when searching "set ignorecaseset incsearch" Set magic onset magic "No sound on errors.set noerrorbellsset novisualbellset tweevb =" How many tenths of a second to blinkset mat=4 "Highlight search thingsset hlsearch" Turn backup offset nobackupset nowbset noswapfile "smart backspaceset backspace=start,indent,eol" switch buffers with Tabmap: bnmap: bp
After some modification, our vim can easily edit .php files. However, there is still a lot of work to be done to build a php development environment.
Build PHP IDE
On the left side of the IDE is the directory navigation, in the middle is the editing area, and on the right is a list of methods that can be used to quickly jump through files that are already open. Pressing CTRL+X in the edit area also displays a list of open files.
Other functions, such as automatic completion, code templates, and so on, are available. Having seen the beautiful screenshot, let's build PHP IDE step by step.
Using NERDTree to realize directory navigation
When developing PHP applications, it is normal to edit multiple files at the same time. So you must have a convenient directory navigation tool to quickly switch between directory structures and find files that need to be edited.
There are many plug-ins that provide this function in vim, such as project, winmanager and so on. But I personally think that it is best to use the plug-in The NERD Tree. NERDTree can not only display the complete directory tree structure, but also set any directory as the root directory. And provides the bookmark function of directory navigation, which is very convenient.
Download address: http://www.vim.org/scripts/script.php?script_id=1658
Download file: NERD_tree.zip
When unzipping, unzip the directory structure in the package completely into the $VIM/vimfiles directory. When you are done, you should find the $VIM/vimfiles/doc/NERD_tree.txt file and the $VIM/vimfiles/plugin/NERD_tree.vim file, respectively. Then enter the command in vim: helptags $VIM/vimfiles/doc to add the help documentation for NERDTree to vim.
Finally, add the following to _ vimrc:
"NERDTreemap: NERDTreeToggle
After restarting vim, press F10 and you will see a directory tree on the left. Press in the directory tree window? Key to view detailed help information.
The most commonly used operation keys are:
In addition, enter the directory: Bookmark favorites name in the directory tree window to add the directory where the cursor is located to the favorites. Next time use: BookmarkToRoot favorites name can be directly to this directory, and this directory as the root directory. More commands can be found in NERDTree's help documentation.
Using taglist to realize Code Navigation
To solve the problem of directory and file navigation, we also need to provide assistance for the jump between code, taglist is such a plug-in. Taglist can list classes, functions, constants, and even variables defined in an open file.
Download address: http://www.vim.org/scripts/script.php?script_id=273
Download file: taglist_45.zip
The zip package needs to be unzipped in its entirety to the $VIM/vimfiles directory and indexed to the taglist plug-in's help documentation with the: helptags $VIM/vimfiles/doc command. The taglist plug-in depends on the ctags program to work. Currently, the commonly used version of ctags is Exuberant Ctags.
Download address: http://ctags.sourceforge.net/
Download file: ec57w32.zip
Just copy the ctags.exe in the package to the $VIM/vim72 directory. Ctags.exe should be in the same directory as gvim.exe.
Finally, add the following to _ vimrc and set up the taglist plug-in:
"= > Plugin configuration" "taglistlet Tlist_Auto_Highlight_Tag = 1let Tlist_Auto_Open = 1let Tlist_Auto_Update = 1let Tlist_Close_On_Select = 0let Tlist_Compact_Format = 0let Tlist_Display_Prototype = 0let Tlist_Display_Tag_Scope = 1let Tlist_Enable_Fold_Column = 0let Tlist_Exit_OnlyWindow = 0let Tlist_File_Fold_Auto_Close = 0let Tlist_GainFocus_On_ToggleOpen = 1let Tlist_Hightlight_Tag_On_BufEnter = 1let Tlist_Inc_Winwidth = 0let Tlist_Max_Submenu_Items = 1let Tlist_Max_Tag_Length = 30let Tlist_Process_File_Always = 0let Tlist_Show_Menu = 0let Tlist_Show_One_File = 0let Tlist_Sort_Type = "order" let Tlist_Use_Horiz_Window = 0let Tlist_Use_Right_Window = 1let Tlist_WinWidth = 40let tlist_php_settings = 'php CRV classpositiveiWR interfacesSitterDRO DRU antantte ffunctionRu
Check the php syntax format in vim
Open your _ vimrc, write and save the following configuration.
"check the current file code syntax (php) {
Function! CheckSyntax () if & filetypetered = "php" echohl WarningMsg | echo "Fail to check syntax! Please select the right file!" | echohl None return endif if & filetype== "php"Check php syntax setlocal makeprg=\" php\ "\-l\-n\-d\ html_errors=off" Set shellpipe setlocal shellpipe= > "Use errorformat for parsing PHP error output setlocal errorformat=%m\ in\% f\ on\ line\% l endif execute" silent make% set makeprg=make execute "normal:" execute "copen" endfunctionmap: call CheckSyntax () "}.
Then we can press F6 to execute. ~ pay attention.
If & filetypewritten = "php" echohl WarningMsg | echo "Fail to check syntax! Please select the right file!" | echohl None returnendif
This paragraph stipulates that the file must be in .php format, so don't try it with the wrong file.
OK, let's test it. Create a new php file, phpinfo.php, and write the following code
Of course, the syntax is obviously wrong, press F6, and the result is as follows:
Modify to
After saving, press F6, and the result is as follows:
These are all the contents of this article entitled "what are the tips for building Vim for custom PHP development tools?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.