tomtom / tcomment_vim

An extensible & universal comment vim-plugin that also handles embedded filetypes
http://www.vim.org/scripts/script.php?script_id=1173
GNU General Public License v3.0
1.4k stars 103 forks source link

Invalid inline comment behavior #300

Open dantezhu opened 2 years ago

dantezhu commented 2 years ago

Env

Steps to reproduce problem:

  1. prepare text line like below:

    abcdefg
  2. type v to enter visual mode, and select ef, like below: image

  3. type gc

  4. the text will changed to:

    abcd/* efg */

    but the right result should be:

    abcd/* ef */g
tomtom commented 2 years ago
the text will changed to:

|abcd/ efg / |

but the right result should be:

|abcd/ ef /g |

You're right of course. The reason for this is that (within the approach of tcomment) there didn't seem to be a reliable way to distingish between the last and the last but one position in a line. Maybe vim/vimscript have changed in the meantime to allow distinguishing between these two situations without having to change too much in the plugin code. If you know of a way to handle this consistently across operating systems, while taking into account all possible option values, please let me know.

dantezhu commented 2 years ago

@tomtom got it, tks

tomtom commented 2 years ago

One more remark: (for this reason) tcomment also supports "comment everything to the right" (r), which should do what you want to achieve.