Copy the configuration for a file rather than capture by reference.
Due to the logic in the alternative delimiter configurator, which swaps the
delimiters when called, every second buffer the script is used swaps the
delimiter order in the original config. This leads to incorrect
delimiters being used in every second buffer.
This change makes a copy for each buffer so swapping the order will not
affect the next loaded buffer.
* Simplify comment delimiter insertion.
* Remove the code that unnecessarily touches the leading spaces/tabs.
* Fix a bug in which `<Plug>NERDCommenterInsert` inserts the comment
delimiters in a wrong position when `col('.')==1`.
Example: `1|234` (cursor at `|`) → `/* */1234`.
* NOTE: Should avoid `feedkey(.., 'ni')` for inserting comment
delimiters to ensure that `NERDCommenter_after` is called after
inserting the delimiters. `feedkey` only adds the input to the queue,
which will be processed after exiting the script context. On the other
hand, `:normal` and `feedkey(.., 'x')` are eagerly processed.
fix 'g:NERDAllowAnyVisualDelims' action.
*'NERDAllowAnyVisualDelims'*
Values: 0 or 1.
Default: 1.
If set to 1 then, when doing a visual or visual-block comment (but not a
visual-line comment), the script will choose the right delimiters to use for
the comment. This means either using the current delimiters if they are
multipart or using the alternative delimiters if THEY are multipart. For
example if we are editing the following java code: >
float foo = 1221;
float bar = 324;
System.out.println(foo * bar);
<
If we are using // comments and select the "foo" and "bar" in visual-block
mode, as shown left below (where '|'s are used to represent the visual-block
boundary), and comment it then the script will use the alternative delimiters
as shown on the right: >
float |foo| = 1221; float /*foo*/ = 1221;
float |bar| = 324; float /*bar*/ = 324;
System.out.println(foo * bar); System.out.println(foo * bar);
<