vim-se-conventions


Ⅰ. 插件描述

Sycamore code conventions made easy.

Ⅱ. 基本信息

创建日期:  2015-08-31
使用用户:  2
Github星:  0
插件作者:  Jon Ronhovde

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'jronhovde/vim-se-conventions'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'jronhovde/vim-se-conventions'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'jronhovde/vim-se-conventions'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/jronhovde/vim-se-conventions

Ⅳ. 文档说明

# vim-se-conventions
Sycamore code conventions made easy.

Version 1.05.6 - Oct 28 2015

Installation/Setup

If you don't have a preferred installation method, I recommend
installing pathogen.vim, and
then simply copy and paste:

cd ~/.vim/bundle
git clone git@github.com:JRonhovde/vim-se-conventions.git 

If not using the Pathogen plugin manager, just create a directory called plugin in your ~/.vim/ folder and place the .vim file from this repo there:

cd ~/.vim
mkdir plugin

Include a visual mode remap for the SEConventions command:

vnoremap <leader>sec <esc>:SEConventions<CR>   

Use this command by visually selecting a block of code (pressing v while in command mode) and the pressing <leader>sec. By default, "<leader>" is set to backslash("").

This command will update most of the HTML contained within visually selected print() statements to Sycamore standards. Starting with v1.05, SEC will also convert SQL 'for' loops to use mysql_fetch_assoc() syntax.

Alternatively, the :SEConventions(:SEC) command accepts line numbers. :SEConventions 100 200 will modify lines 100 to 200, inclusive. Given only one argument, it will modify from that line to the end of the file.

If you encounter any problems, try updating the plugin from git:

cd ~/.vim/bundle/vim-se-conventions    
git pull origin master    

If the problem persists, it can be brought to my attention by creating an issue on GitHub

Comprehensive list:

Add

  • table class to all TABLE elements
  • se-bold class to all TR elements that have gray backgrounds (#cfcfcf or se-bg-gray)

Remove

  • width=100% or width:100% from TABLE
  • background-color:white; or #ffffff;
  • bgcolor=white or #ffffff;
  • border=0
  • cellpadding=#
  • cellspacing=#
  • newline chars \npreceding the end of a print statement ");
  • href='' and return false;
  • HTML width= or CSS width: from TR elements
  • <font> and </font> tags that contain face=$titlefont and size=1 or 2 when
  1. TABLE element has the cooresponding font class (size=1 -> se-font-small and size=2 -> se-font)
  • <B> tags and se-bold classes contained within TR elements with the se-bold class
  • Left text alignment (HTML, CSS, or se-left class) on TD elements
  • Empty style and class attributes
  • Extra spaces within HTML elements and around opening and closing parentheses for print() statements

Replace/Change

  • Gray(#cfcfcf), light gray(#efefef), pink(#ffcfcf), and school color($titlefont) background colors to
  1. respective se-bg classes
  • <font> tags with face=$titlefont and size=1 or 2 (opposite of the font class on the TABLE element) to
  1. appropriate class on the TD
  • width attributes on TD and TABLE elements to CSS properties
  • Right and center text alignment (HTML or CSS) to appropriate se- class
  • for($i=0;$i<$rsc;$i++) to while($mysql_row = mysql_fetch_assoc($rs)) {.
  • $var = mysql_result($rs, $i, "Var") to $var = $mysql_row["Var"]

Unchanged

  • TR height attributes
  • <font> tags that contain attributes other than face=$titlefont and size=1 or 2
  • <font> tags not preceded by a TD element on the same line
  • Anything that would normally be replaced by:
        .se-red
        .se-tall-row
        .se-font-title
        .se-top
        .se-nowrap
        .se-nobold
        .se-wrap
        .se-striped-green    
        printf() lines

添加新评论