VIM for PHP Development Environment

Source: Internet
Author: User
Tags imap php development environment
Blog.sina.com.cnsblog_73ca27ba0100r1u3.html changed the annotation plug-in NER_commenter, and the function failed to find a solution. So I changed to the plug-in EnhancedCommentify handler and finally finished vim after four days.

Http://blog.sina.com.cn/s/blog_73ca27ba0100r1u3.html replaced the annotation plug-in NER_commenter, function error cannot find the solution, so Replace with the plug-in EnhancedCommentify --------------------------------------------------------- four days finally get vim almost done

Http://blog.sina.com.cn/s/blog_73ca27ba0100r1u3.html


The annotation plug-in NER_commenter is replaced, and the solution cannot be found when a function error occurs, so it is replaced with the plug-in EnhancedCommentify.

-----------------------------------------------------------------

After four days of hard work, we finally completed vim's implementation of directory, function jump, annotation and php automatic indent, and automatic completion. Coming soon
The vimrc code is as follows:

"Set leader,
Let mapleader = ","
Let g: mapleader = ","
Set nocompatible "Disable vi compatibility mode
Syntax on "Automatic syntax highlighting

Set mouse = "Enable mouse Mode
Filetype plugin indent on "Enable Plug-ins
Set number "Display row number
Set nocursorline "Do not highlight the current row
Set shiftwidth = 4 "Set <and> the width of the command to 4
Set softtabstop = 4 "This allows you to delete four spaces at a time when you press the backspace key.
Set tabstop = 4 "Set the tab length to 4
Set nobackup "Do not back up when overwriting files
Set autochdir "Automatically switch the current directory to the directory where the current file is located
Set backupcopy = yes "Set the backup behavior to overwrite
Set ignorecase smartcase "Case Insensitive during search, but case sensitive when one or more uppercase letters exist
Set nowrapscan "Re-searching is prohibited when both ends of the file are searched.
Set incsearch "The search result is displayed when you enter the search content.
Set hlsearch "Highlight the found text when searching
Set noerrorbells "Close error message ring
Set novisualbell "Disable the use of visual bell instead of call
Set t_vb = "Terminal code for setting an empty wrong ringtone
"Set showmatch "When parentheses are inserted, the matching parentheses are jumped temporarily.
"Set matchtime = 2 "Jump to the matching bracket for a short time
"Set nowrap "Do not wrap automatically
Set magic "Display matching of parentheses
Set hidden "Switch the buffer when there are unsaved changes. vim is responsible for saving the changes.
Set smartindent "Use Smart auto indent when new rows are enabled
Set cindent "C-style program indent
Set cinoptions = {s, t0, N-2, p2s, (03 s, =. 5 s,> 1 s, = 1 s,: 1 s

Set backspace = indent, eol, start "cannot be used to Delete carriage return characters in the insert status
Set Partition Height = 1 "Set the number of lines in the command line to 1.
Set laststatus = 2 "Display status bar (the default value is 1, and the status bar cannot be displayed)
Set foldenable "Start folding
Set foldmethod = syntax "Set syntax collapse
Set foldcolumn = 0 "Set the width of the collapsed area
Setlocal foldlevel = 1 "Set the folding layers
"Set foldclose = all "Set to automatically disable collapse
"Colorscheme colorzone "Set the color scheme
Colorscheme default "Set the color scheme

"Set the information displayed in the status line
Set statusline =\% <% F [% 1 * % M % * % n % R % H] %=\% y \ % 0 (% {& fileformat} \ [% {(& fenc = ""? & Enc: & fenc). (& bomb? ", BOM": "")}] \ % c: % l/% L % )\

"Display Tab character
:., Extends:>, precedes: <
Set listset listchars = tab:>-, Trail

"Set the code folding mode to manual indent.
Set foldmethod = indent

"Sets the number of lines displayed after the code block is collapsed.
Set foldexpr = 1
If has ("gui_running ")
Set guioptions-= m "hide the menu bar
Set guioptions-= T "Hide Toolbar
Set guioptions-= L "hide the left-side scroll bar
Set guioptions-= r "hide the scroll bar on the right
Set guioptions-= B "hide the bottom scroll bar
Set showtabline = 0 "hide the Tab bar
Endif

"Automatically maximized after startup

If has ("win32 ")
Au GUIEnter * simalt ~ X
Endif

"Vim supports Chinese Characters
Set enc = UTF-8
Set fencs = UTF-8, ucs-bom, shift-jis, gb18030, gbk, gb2312, cp936
Set langmenu = zh_CN.UTF-8
Language message zh_CN.UTF-8
Set guifont = NSimSun: h8
Set helplang = cn
Set ambiwidth = double

"Php indent
Let PHP_autoformatcomment = 1

"-------------------------------------------------------

"Shortcut key
"Search for the selected text in full text. Selected, F
: Vmap F y/ = Escape (@ ", '\/. * $ ^ ~ [] ')
: Vmap F y? = Escape (@ ", '\/. * $ ^ ~ [] ')
"Delete spaces before and after all rows. Shortcut Key f12
Nmap : % S/[\ t \ r] \ + $/g
"Buffers operation shortcut! Switch the shirt + l. shift + h file
Nmap : Bnext
Nmap : Bprevious
"Switch window. Ctrl + w + whjkl
Nmap H
Nmap J
Nmap K
Nmap L
"Nmap W
"Move the cursor left and right in insert mode
"Imap La
"Imap Ha

"Copy in selected state Ctrl + c
Vmap "+ Y

"Ing conversion syntax. Shortcut: html:, 1 Php:, 2 Javascript, 3 Css, 4 defalur, 5
Nmap 1: set filetype = xhtml
Nmap 2: set filetype = css
Nmap 3: set filetype = javascript
Nmap 4: set filetype = php
Nmap 5: set filetype = default

"Php syntax detection ctrl + p start
Map :! /Php/bin/php-l %

"Php startup help shortcut key in Normal Mode K
Autocmd BufNewFile, Bufread *. ros, *. inc, *. php set keywordprg = "help

"Saved quickly. , Wq is saved and exited., Qq does not save quit all, w save all ctrl + w insert mode save
Nmap Wq: wqa

Nmap Qq: qa!
Nmap W: w!

"Enable and disable the paste Mode

: Set pastetoggle =

"-------------------------------------------------------

"Indentation of different file types
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 completeopt = longest, menu

"-----------------------------------------------------------------

"Plugin-Mark. vim marks different colors for various tags, allowing you to conveniently view and adjust the plug-ins.
" , Hl "highlight words or text under the cursor
" , Hh clears the highlight of the word. If you enter a highlighted word, all highlighted words are cleared.
" , Hr to highlight the text that matches the input of a regular expression
Nmap Hl MarkSet
Nmap Hh MarkClear
Nmap Hr MarkRegex
Vmap Hl MarkSet
Vmap Hh MarkClear
Vmap Hr MarkRegex
"You can use", # "or", * "to highlight the text. When ", #" or ", *
"", You can directly enter "#" or "*" to continue searching for the highlighted text until you use "#" or"
"*" Found other text.

"-----------------------------------------------------------------

"Plugin-EnhCommentify. vim Used to annotate code,

" C. After this annotation, the cursor will jump to the next line.

" X with this annotation, the cursor remains in the current row.


Nmap , X
Vmap , X
Imap , X

Let g: EnhCommentifyUseSyntax = 'yes' "Automatically comment according to the type
Let g: EnhCommentifyMultiPartBlOcks = 'yes' "Do not add a annotator to each line when you annotate multiple rows.

Let g: EnhCommentifyAlignRight = 'yes' "Automatic annotation alignment
"Let g: EnhCommentifyRespectIndeNt = 'yes' "Comment close to code

Let g: EnhCommentifyPretty = 'yes' "Adding spaces between comments and text

"-----------------------------------------------------------------

"Plugin-NERD_tree.vim: Tree View of files and directories in the system
": ERDtree open NERD_tree : NERDtreeClose Disable NERD_tree
"NERDTree Enable and disable
Map : NERDTreeToggle
"O Open and Close files or directories
! Execute this file
"P to the upper directory P to the root directory
"K to the first node J to the last Node
"U open the upper directory M: displays the file system menu (add, delete, and move operations)
"R recursively refresh the current directory R recursively refresh the current root directory

"-----------------------------------------------------------------
"Plugin-NeoComplCache. vim Automatic completion plug-in
"Auto-completion combined with supertab plug-in use tab to complete or ctrl + n
"Imap
Let g: neocomplcache_enable_at_startup = 1 "Use smartcase.
Let g: neocomplcache_enable_smart_case = 1 "Use camel case completion.
Let g: neocomplcache_enable_camel_case_completion = 1 "Use underbar completion.
Let g: neocomplcache_enable_underbar_completion = 1 "Set minimum syntax keyword length.
Let g: neocomplcache_min_syntax_length = 3
Let g: neocomplcache_lock_buffer_name_pattern = '\ * ku \*'
"Define dictionary.
Let g: NeoComplCache_DictionaryFileTypeLists = {'default': '', 'php': '/usr/share/vim/vim70/dict/php. dict '}
"Imap (Neocomplcache_snippets_expand)
"Smap (Neocomplcache_snippets_expand)
"Define keyword.
If! Exists ('G: neocomplcache_keyword_patterns ')
>-Let g: neocomplcache_keyword_patterns = {}
Endif
>-Let g: neocomplcache_keyword_patterns ['default'] = '\ h \ w *'

"-----------------------------------------------------------------

"Plugin-supertab Smart tab plug-in
"Tab key auto-completion
Let g: supertabdefacomplecompletio NType =" "

"-----------------------------------------------------------------

"Plugin-bufexplorer. vim Buffers Switch
" Open the file list window (up/down)
Map Bs
", Be full screen view of the list of all open files
", Bv left and right view , Bs upper/lower View
"Shortcut for switching Buffers: shirt + l. shift + h
Let g: bufExplorerDefaultHelp = 0 "Do not show default help.
Let g: bufExplorerShowRelativeP Ath = 0 "Do not show relative path (full path)
Let g: bufpolicersortby = 'mru' "Sort by most recently used.
Let g: bufExplorerSplitRight = 0 "Split left.
Let g: bufExplorerSplitBelow = 0 "Split new window above current

"-----------------------------------------------------------------

"Plugin-Tlist related settings
" Enable and disable

Map : TlistToggle
Let Tlist_Auto_Highlight_Tag = 1
Let Tlist_Auto_Open = 0let 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 = 1

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 = 20
Let tlist_php_settings = 'php; c: class; I: interfaces; d: constant; f: function'

"-----------------------------------------------------------------

"Folding settings
Set diffexpr = MyDiff ()
Function! MyDiff ()
Let opt = '-a -- binary'
If & diffopt = ~ 'Icase' | let opt = opt. '-I' | endif
If & diffopt = ~ 'Iwhite' | let opt = opt. '-B' | endif
Let arg1 = v: fname_in
If arg1 = ~ ''| Let arg1 = '"'. arg1. '"' | endif
Let arg2 = v: fname_new
If arg2 = ~ ''| Let arg2 = '"'. arg2. '"' | endif
Let arg3 = v: fname_out
If arg3 = ~ ''| Let arg3 = '"'. arg3. '"' | endif
Let eq =''
If $ VIMRUNTIME = ~ ''
If & sh = ~ '\ Let cmd = '""'. $ VIMRUNTIME. '\ diff "'
Let eq = '"'
Else
Let cmd = substitute ($ VIMRUNTIME, '', '"', ''). '\ diff "'
Endif
Else
Let cmd = $ VIMRUNTIME. '\ diff'
Endif
Silent execute '! '. Cmd. ''. opt. arg1.''. arg2.'> '. arg3. eq
Endfunction

The list of installed plug-ins is as follows:
Omnicppcomplete-0.41.zip: Achieve Automatic completion of the Tab key or ctrl + l
Vim-php-manual.tar.gz: php function documentationK key
Supertab. vba: Implement tab key completion
Taglist_45.zip: generate the function list on the right
NERD_tree.zip: directory tree on the left of the vim Interface
Mattn-zencoding-vim-88d8991.zip: generating html
// NERD_commenter.vim Used to annotate code,

EnhancedCommentify annotation plug-in
Php dictionary file
Mark.vba.gz flag
Javascript.zip
Css. vim
Php. vim (PHP-correct-Indenting latest php indent vim)
And so on

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.