From faaaed9840d6fb13f0700366db1387424d1a17ea Mon Sep 17 00:00:00 2001 From: mattn Date: Thu, 7 Jun 2012 12:50:07 +0900 Subject: [PATCH] new feature, add code pretty. --- autoload/zencoding.vim | 23 ++++++++++++++++++++++- plugin/zencoding.vim | 3 ++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/autoload/zencoding.vim b/autoload/zencoding.vim index eaf0f36..5c98912 100644 --- a/autoload/zencoding.vim +++ b/autoload/zencoding.vim @@ -1,7 +1,7 @@ "============================================================================= " zencoding.vim " Author: Yasuhiro Matsumoto -" Last Change: 04-Jun-2012. +" Last Change: 07-Jun-2012. let s:save_cpo = &cpo set cpo&vim @@ -520,6 +520,27 @@ function! zencoding#anchorizeURL(flag) call zencoding#util#setContent(block, expand) endfunction +function! zencoding#codePretty() range + let type = input('FileType: ', '', 'filetype') + if len(type) == 0 + return + endif + let block = zencoding#util#getVisualBlock() + let content = zencoding#util#getContent(block) + silent! 1new + let &l:filetype = type + call setline(1, split(content, "\n")) + let old_lazyredraw = &lazyredraw + set lazyredraw + silent! TOhtml + let &lazyredraw = old_lazyredraw + let content = join(getline(1, '$'), "\n") + silent! bw! + silent! bw! + let content = matchstr(content, ']*>[\s\n]*\zs.*\ze') + call zencoding#util#setContent(block, content) +endfunction + function! zencoding#ExpandWord(abbr, type, orig) let mx = '|\(\%(html\|haml\|slim\|e\|c\|fc\|xsl\|t\)\s*,\{0,1}\s*\)*$' let str = a:abbr diff --git a/plugin/zencoding.vim b/plugin/zencoding.vim index 75dc4f1..64b7fcb 100644 --- a/plugin/zencoding.vim +++ b/plugin/zencoding.vim @@ -1,7 +1,7 @@ "============================================================================= " File: zencoding.vim " Author: Yasuhiro Matsumoto -" Last Change: 04-Jun-2012. +" Last Change: 07-Jun-2012. " Version: 0.72 " WebPage: http://github.com/mattn/zencoding-vim " Description: vim plugins for HTML and CSS hi-speed coding. @@ -120,6 +120,7 @@ function! s:install_plugin() \ {'mode': 'n', 'var': 'user_zen_anchorizeurl_key', 'key': 'a', 'plug': 'ZenCodingAnchorizeURL', 'func': ':call zencoding#anchorizeURL(0)'}, \ {'mode': 'i', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': ':call zencoding#anchorizeURL(1)a'}, \ {'mode': 'n', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': ':call zencoding#anchorizeURL(1)'}, + \ {'mode': 'v', 'var': 'user_zen_codepretty_key', 'key': 'c', 'plug': 'ZenCodingCodePretty', 'func': ':call zencoding#codePretty()'}, \] if !hasmapto(''.item.plug, item.mode)