Useful Vim plugins for web development and design (php, html, css, javascript)? [closed]
Right now I'm using surround.vim
to enclose text in HTML tags, and a plugin that highlights text according to the hex value in the CSS file (e.g. #888 will have gray background in the CSS file).
Are there other useful plugins for web development?
Recommendations
Here is a list of the plugins mentioned in the answers so far:
- surround.vim to enclose text in HTML tags
- jslint.vim to check开发者_JAVA百科 for JavaScript errors with JSLint
- Emmet.vim for HTML and CSS high-speed coding
- phpfolding.vim to for automatic folding of PHP
- Syntastic for automatic syntax checking of e.g. PHP
- Exuberant ctags for tagging of a wide array of languages.
- Tagbar Helps view/navigate source, displays call signature in status area.
I've written answers for this question and this question explaining how to get JavaScript syntax checking / linting and source-code browsing / tag-list for Vim using the community-driven jshint.com (which is way better than JSLint IMO) and Mozilla's DoctorJS (formerly jsctags).
I find Syntastic to be fairly helpful in spotting minor PHP problems. (and/or blend it with some form of setting php -l as :make.) Syntastic also shows you tidy warnings on your html.
How about JSLint right in VIM, http://github.com/hallettj/jslint.vim ?
Here are the plugins I'm currently using as well as some vimrc mappings to make things a bit easier.
Plugins
Pathogen is an essential vim plugin for every user. It helps keep all the plugins you need organized within their own directories. This makes it much easier to uninstall plugins at a later time, since your plugins don't all live in the same tree. Pathogen will handle adding everything together at runtime.
Command-T adds the popular textmate feature that makes it easy to open files.
Snipmate gives vim the power of textmate like snippets.
Sparkup adds zencoding to vim to make it faster and easier to write HTML.
NERDCommenter makes it easy to toggle commented blocks of code.
Syntastic adds syntax checking to lots of different file types, and if vim has signs support enabled, you get markers to the left of your line numbers telling you where your errors are.
.vimrc config settings
Encode/Decode HTML to HTML Entities (Great for writing documentation)
"EASILY ESCAPE OR UNESCAPE HTML
function HtmlEscape()
silent s/&/\&/eg
silent s/</\</eg
silent s/>/\>/eg
endfunction
function HtmlUnEscape()
silent s/</</eg
silent s/>/>/eg
silent s/&/\&/eg
endfunction
map <silent> <c-h> :call HtmlEscape()<CR>
map <silent> <c-u> :call HtmlUnEscape()<CR>
Toggle Relative Line Numbers (new VIM 7.3 feature)
function! g:ToggleNuMode()
if(&rnu == 1)
set nu
else
set rnu
endif
endfunc
nnoremap <C-L> :call g:ToggleNuMode()<cr>
Highlight unwanted whitespace
"HIGHLIGHT POTENTIALLY UNWANTED WHITESPACE
highlight BadWhitespace term=standout ctermbg=red guibg=red
match BadWhitespace /[^* \t]\zs\s\+$\| \+\ze\t/
I like ZenCoding : http://www.vim.org/scripts/script.php?script_id=2981
Also, for folding Php : http://www.vim.org/scripts/script.php?script_id=1623
NERDTree, minibufexpl
ctags aka Exuberant ctags
A blog post about it.
That blog post also mentions the taglist plugin, which I have yet to use.
Very helpful when dealing with html or xml: surround.vim; it allows to easily add/delete/change any kind of tags.
Adapted by someone else from a couple of functions of mine (in turn adapted from others), this plugin allows you to turn "special" characters into HTML entities (and back) or URL Escapes (and back).
This is extremely useful when writing stupid HTML Emails.
精彩评论