2010年11月13日
The tcomment vim plugin
In this video of the tcomment vim plugin we demonstrate the gc operator and automatic recognition of filetypes.
In a HTML paragraph, we type gcip (that is gc + ip for "inner paragraph" to comment this paragraph out (and then again to uncomment it). Since this paragraph contains HTML syntax, tcomment recognizes it as HTML and uses the appropriate markup.
We then use <c-_>b to comment the visually selected paragraph as block.
We try the same with PHP code.
In a HTML paragraph, we type gcip (that is gc + ip for "inner paragraph" to comment this paragraph out (and then again to uncomment it). Since this paragraph contains HTML syntax, tcomment recognizes it as HTML and uses the appropriate markup.
We then use <c-_>b to comment the visually selected paragraph as block.
We try the same with PHP code.
Labels:
tcomment
Subscribe to:
Post Comments (Atom)
13 comments:
May I ask what keys exactly I have to press for the combination < c - _ > b?
Reply DeleteI think I'm a slightly experienced Vim user, but I've never seen this combination nor does the Vim help file or Google know anything about it.
This comment has been removed by the author.
DeleteTo get an answer to this enter
Delete:help <>
Basically means pressing the control and the "_"-key. Unfortunately, for different operating systems, GUIs, and different keyboards layouts this requires pressing different keys.
Reply DeleteIf you cannot find out which combination is , I'd suggest to change the default tcomment map leader (the default is '') by setting the variable g:tcommentMapLeader1 in your vimrc file.
HTH
Can't toggle comments:
Reply Delete<!-- <xmlnode value="true" /> -->
@coresh: If the filetype is set to xml, the above example works perfectly well. What happens if you press gcc?
Reply DeleteRegarding to above, seems to be a local/temporary issue. Fixed by: restarting vim.
Reply DeleteAfter un-commenting source code in example of above, unnecessary spaces located after tag "/>...........$"
PS: unnecessary trailing white space, which is usually deleted by command: ":%s/\s\+$//"
Reply DeleteUsing the code example here : https://gist.github.com/1506036
Reply DeleteI experience a bug which duplicate '\' each time I toogle Comment.
I place the cursor on the desired line select visually the line then I type :TComment
and my line which previously was printf("toto%d\n"); becomes printf("toto%d\\\\\n");
@totouser That was a problem of an older version of the plugin that should have been fixed in version 1.03. If the problem persists with the current version, please file a bug report at https://github.com/tomtom/tcomment_vim/issues
Reply DeleteThanks I was using an another repository on Github it's fixed now. And will use github Issues for my next problem.
Reply Deletetest comment
Reply DeleteOkay
Reply Delete