" File : EasyHtml.vim " Last Change: 2002 Feb 18 " Maintainer: Gontran BAERTS " Version: 0.5.1 "+++ Cream: additions " " Changes by Cream are generally enclosed in "+++" brackets. " " * Removed dependency on libList in favor of multvals.vim version " 2.5.0+ (http://vim.sourceforge.net/script.php?script_id=171). " Mostly involved de-modularizing a few single statments out of the " called functions back here. (De-modularization--sorry!) " * Commented the mapping in this file. " * Added the dialog call just below. " * Added slight more coloration to warning on "Not Found". " * Slightly altered find-word-under-cursor behavior for better or " worse. " * Force file type detection each use. (Temporarily?) " * Added folds and fold-sensitive modeline " "+++ "+++ Cream: Add calling function for dialog and detection. " prompt for language function! Cream_EasyHtml_call() " set default menu pick if &fileformat == "html" let default = 1 elseif &fileformat == "css" let default = 3 else " default to Cancel in case of accidental activation ;) let default = 4 endif let n = confirm( \ "Please select list to display.\n" . \ "\n", "&HTML Tags\nHTML Tag &Attributes\nC&SS Properties\n&Cancel", default, "Info") if n == 1 " HTML Tags (Example: ) call LaunchEasyHtml('<') elseif n == 2 " HTML Tag Attributes (Example:
) call LaunchEasyHtml('\s') elseif n == 3 " CSS Attributes (Example: margin: ;) call LaunchEasyHtml('\(\s\\|"\\|;\)[a-zA-Z-]\+:') else return endif " remember what buffer we're in let mybufnr = bufnr("%") " reset window configuration call Cream_window_setup() " restore cursor to buffer's new window call MoveCursorToWindow(bufwinnr(mybufnr)) endfunction "+++ " Description {{{1 " " Please don't hesitate to correct my english :) " Send corrections to " "----------------------------------------------------------------------------- " Description: With EasyHtml, you no longer need to look for tags attributes, " attributes values or CSS properties values while editing HTML files. " EasyHtml let you select the right attribute or value by showing you an " attributes/values list for the tag/attribute/CSS property under the cursor. " "----------------------------------------------------------------------------- " To Enable: Normally, this file will reside in your plugins directory and be " automatically sourced. If not, you must manually source this file" using : " source EasyHtml.vim " "----------------------------------------------------------------------------- " Usage: Move the text cursor on the tag, attribute, or CSS property word " then : " - Press key to display attributes for the tag before/under the " cursor " - Press key to display values for the attribute before/under the " cursor " - Press ket to display values for the CSS Property befor/under " the cursor " " " In the EasyHtml buffer, use : ",,, keys to change selected " item. " - / or , keys to scroll list one page " downward/forward. " - or to select the first item. " - or to select the last item. " - to add selected item WITHOUT exiting from items list. " - to add selected item AND exit from items list. " - q or to exit without adding selected item. " " Deprecated attributes as declared by W3C are red highlighted, while right " attributes are blue highlighted. " " Set g:easyHtmlSplitRight variable to 0 or 1 to open items list at left " or right of current window. By default, use splitright setting. " " Set g:eh_singlequote variable to 0 (default) or 1 to use double or single " quote when adding attributes (For example id="" or id='') " " Set g:eh_incsearch variable to 0 (default) or 1 to dis- or en-able " incremental list search. This feature allows to select an item by typing its " beginning. When this is enable, 'q', 'h', 'j', 'k' and 'l' keys aren't used " to exit from list and to move highlighting. Use 'Q', '', '', " '' and '' instead. " " Set g:eh_atfirstplace to 0 (default) or 1 to indicate if attributes must be " added at the end or at the beginning of the tag. " " Useful mappings : " . d : delete tag before/under cursor " . d : delete attribute before/under cursor " "----------------------------------------------------------------------------- " Updates: " in version 0.5.1 " - No longer use of the modifiable option. " " in version 0.5 " - Now use liblist.vim script to handle lists and genutils.vim script to " handle windows (Thanks to Hari Krishna Dara for this script). " Download them at " http://vim.sourceforge.net/scripts/script.php?script_id=166 " and " http://vim.sourceforge.net/scripts/script.php?script_id=197 " Make script smaller. " - Mapping changed ! " displays tag attributes " displays attributes values " displays CSS Properties values " no longer close list after item addition. Use to add and " exit from list. " - More user friendly : you no longer need to move cursor exactly on the " keyword. Cursor may stay on '=', ':' or '"' signs just after keyword while " hitting , or keys. " For example, " . Tags : key works while cursor is at '<' sign. " . Attributes : style="" " Hitting key works while cursor is at '=' or '"' signs. " . CSS properties : background-color:; " Hitting key works while cursor is at ':' or ';' signs. " - New mappings : " . d : delete tag before/under cursor " . d : delete attribute before/under cursor " - New g:eh_atfirstplace variable. See Usage section above. " - Fix modifiable setting again " - Fix syntax error for the "frame" attribute of tag which causes " "border" attribute to not been seen in attributes list. " " in version 0.4.1 " - Fix infinite loop to find window when easyhtml buffer is hidden. Thanks to " Jonathon Merz who pointed out the bug and send me the patch. " " in version 0.4 " - Added values for the "style" attribute (CSS2 properties) " - Added values for CSS2 properties " - and are now usable to move highlight through the list " - When adding a value for an attribute, current attribute value (if exists) " is replaced by the selected one, except for "style" attribute for which " values are append " - Set g:eh_singlequote variable to 0 or 1 to use double or single quote when " adding attributes (For example id="" or id='') " " in version 0.3 " - Attributes list updated " - Don't display attributes list for closing tags " - Now, display values list when hitting with cursor on attribute word " (for some attributes only). " " in version 0.2.1 " - Fix global modifiable setting instead of local " " in version 0.2 " - Attributes list is now alphabetically sorted " - Hitting allows to display attributes list in Insert mode too " - Allows to select an attribute by incremental search :-) " For example, with tag, typing "onk" (normal mode) in the attributes " list buffer automatically select "onkeydown" attribute. Use backspace " () to remove characters. This behavior is enable by setting " g:eh_incsearch variable to 1. Warning : when incremental attribute search " is on, 'q', 'h', 'j', 'k' and 'l' keys aren't used to exit from list and " to move highlighting. Use 'Q', '', '', '' and '' " instead. " - Check for attributes list already opened, and reuse it " " in version 0.1 " - First version " 1}}} " Init {{{1 " Has this already been loaded ? if exists("loaded_easyhtml") fini en let loaded_easyhtml=1 if !exists("g:easyHtmlSplitRight") let g:easyHtmlSplitRight = &spr en if !exists("g:eh_incsearch") let g:eh_incsearch = 0 en if !exists("g:eh_singlequote") let g:eh_singlequote = 0 en if !exists("g:eh_atfirstplace") let g:eh_atfirstplace = 0 en " ** " Mappings: {{{1 " ** "+++ Cream: don't use these insert mode mappings " Tag deletion nm d lF " Attribut deletion nm d lF d2f" " Left move attribut nm d " Right move attribut nm d/ \\|>:nohlP " Tag attributes list nm :cal LaunchEasyHtml('<') "im a " Attributes values list nm :cal LaunchEasyHtml('\s') "im a " Style attribut values list nm :cal LaunchEasyHtml('\(\s\\|"\\|;\)[a-zA-Z-]\+:') "im a "+++ " 1}}} "** " Script Variables: "** let s:srch = "" let s:maxAttrLength = 0 let s:currentPos = 2 let s:itemAdded = 0 " HTML tags attributes (original) {{{1 let s:coreattrs = "id=\"\" class=\"\" style=\"\" title=\"\"" let s:i18n = "lang=\"\" dir=\"\"" let s:events = "onclick=\"\" ondblclick=\"\" onmousedown=\"\" onmouseup=\"\" onmouseover=\"\" onmousemove=\"\" onmouseout=\"\" onkeypress=\"\" onkeydown=\"\" onkeyup=\"\"" let s:cellhalign = "align=\"\" char=\"\" charoff=\"\"" let s:cellvalign = "valign=\"\"" let s:attrs = "%coreattrs %i18n %events" let s:HTMLTags = "