Wikia

Vim Tips Wiki

Script:3048

Talk0
1,612pages on
this wiki
Revision as of 09:49, July 14, 2012 by JohnBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Use this page to discuss script 3048 vicom: intelligent line commenter

  • Add constructive comments, bug reports, or discuss improvements (see the guideline).
  • Do not document the script here (the author should do that on vim.org).
  • This page may be out of date: check the script's vim.org page above, and its release notes.

ProblemsEdit

Despite considerable development effort, this plugin has substantial downsides:

  • It directly modifies the user's .vimrc file each time Vim is launched, hard-wiring mappings for the comment type based on the final filename argument passed on the command line, rather than based on Vim's 'filetype' option. Therefore:
    • The comment style is global, not specific to a given buffer's filetype.
    • The comment style cannot be changed within a running instance of Vim.
    • Newly opened files will use the hard-wired comment type determined at Vim startup.
    • Filetype determination is done exclusively based on filename extension according to hard-wired assumptions in the plugin. A ".c" file gets comments like this:
      /** This was commented out. **/
      This comment style is broken for users of Doxygen, as the leading "/**" indicates a Doxygen comment, not a normal C comment.
  • The user's Vim environment is heavily polluted by the plugin:
    • Several mappings are made which collide with standard Vim functionality. Overridden functionality includes:
      • Ctrl-X (insert-mode completion, normal-mode decrementation)
      • Ctrl-Y (insert character above cursor, normal-mode scroll down)
      • b (back by one word)
      • t (move "till" occurrence of character on line)
      • Ctrl-W (window commands); this mapping has nothing to do with the plugin's purpose, but is nevertheless forced into ~/.vimrc
    • The user's search and substitute histories are polluted by the comment/uncomment functionality.
    • 'hlsearch' is forced off. If turned back on, use of the plugin leaves the regex "." active in some cases, highlighting every character in the file.
    • The mark "y" is clobbered and not restored by the plugin.
  • It operates as a wrapper executable around Vi instead of a standard plugin. The wrapper is launched by shell aliases. Therefore:
    • It cannot be used for Vim sessions launched from a menu, because launching Vim directly bypasses the plugin's wrapper executable.
    • It requires compilation of the plugin.
    • It makes heavy use of GNU autoconf, tying it to Unix-like systems.
  • It directly modifies the user's ~/.bashrc file to insert broken aliases for vi and gvim, but strangely, not vim. The aliases lack the "=" required by the alias command:
alias vi 'vicom -m vim -- '    # alias added by vcominst
alias gvim 'vicom -m gvim -- ' # alias added by vcominst
  • The plugin is hard to modify and extend:
    • Filetype-specific comment styles are hardwired into the plugin source code. Adjustments for new filetypes must be done in the C++ source, and the plugin must be recompiled and reinstalled.
    • Filetypes are arbitrarily mapped to coded integers. Distributed throughout the source code are comparisons against these integers to control comment style and other settings. Hardwired assumptions are made about the relative ordering and meaning of these arbitrary integers, making it difficult to add, remove, or modify the file-specific settings.
  • The plugin is overly complex, yet provides minimal functionality.
    • The plugin comprises over 2300 lines of C++ source code.
    • The useful per-filetype functionality boils down to a pair of overly simplisitic mappings which are forced into ~/.vimrc. For C code, these are:
map <C-X> ^i/** <Esc>A **/<Esc>^ $/.<CR>
map <C-Y> ^my^:s!\/\** <Esc>:s/\([^*]*\) \*\*\//\1<Esc>/\/\*\* <CR>/.<CR>

It seems a shame to see this amount of plugin development effort wasted. There are some excellent alternatives to this plugin, and they are easily found with Vim.org's plugin search facility (http://www.vim.org/scripts/script_search_results.php). When searching for "comment", the top search results are deservedly famous in the Vim community. Simple research would have turned up these superior plugins:

Drmikehenry 11:14, April 10, 2010 (UTC)

CommentsEdit

Around Wikia's network

Random Wiki