Txtfmt-plugin and txtfmtBgColor

18 views
Skip to first unread message

Michael Maurer

unread,
Jan 4, 2010, 4:15:45 AM1/4/10
to vim...@googlegroups.com
The following concerns the Txtfmt (The Vim Highlighter)-plugin by
Brett Stahlmann. I hope this is not too specific for this list.
I'm using Txtfmt with GVim under Windows XP SP3. After enabling all
background colors via

let b:txtfmt_cfg_bgcolormask=11111111

I try to hightlight a sentence as yellow. To do this, I press \i
followed by ky. But instead of a yellow bgColor, I get this symbol:

Ì

Blue and green on the other hand work just fine.

Cheers,
Michael


--
Du bist meine kleine Gummizelle
http://michaelmaurer.net/archives/2009/11/14/du_bist_meine_kleine_gummizelle/index.html

Stahlman Family

unread,
Jan 4, 2010, 8:42:23 AM1/4/10
to vim...@googlegroups.com

Michael Maurer wrote:
> The following concerns the Txtfmt (The Vim Highlighter)-plugin by
> Brett Stahlmann. I hope this is not too specific for this list.
> I'm using Txtfmt with GVim under Windows XP SP3. After enabling all
> background colors via
>
> let b:txtfmt_cfg_bgcolormask=11111111

Michael,
b:txtfmt_cfg_bgcolormask is the internal variable used by the plugin;
setting it won't have any effect. (If you set it before the plugin
loads, it will be overwritten; if you set it afterward, it won't be able
to affect the syntax regions responsible for highlighting, which have
already been defined.) The option variable you should set is
g:txtfmtBgcolormask.

:help txtfmtBgcolormask

Note that this variable *must* be set *before* the plugin is loaded so
that it can affect the syntax regions created. If you're setting the
option globally, you probably want to put it in your .vimrc.
Alternatively, you could set it in an autocommand, or even in a "Txtfmt
modeline" within the file itself. Note that if you use a modeline, the
variable name is bgcolormask or bcm. E.g.,

vim:ft=txtfmt
txtfmt:bcm=01101010

:help txtfmt-modeline

You can easily see which colors are active in a Txtfmt buffer (i.e.,
which ones are defined by the syntax) by running...

:ShowTokenMap<CR>

Of course, this command is available only in a Txtfmt buffer. In theory,
it could actually yield different results in different Txtfmt buffers,
since option variables like txtfmtBgcolormask can be set either globally
(g:) or buffer-locally (b:), but I'm guessing that most users override
the color masks globally...

One final note: for performance reasons, I would recommend activating
only the colors you plan to use. If you decide later that you want more,
you can always activate them at that time without adversely affecting an
existing file. As explained in the help, the number of colors activated
has a significant impact on the number of syntax regions created, which
in turn impacts the speed of syntax highlighting redraw...

:help txtfmt-performance-considerations

Let me know if this fixes the problem for you...

Thanks,
Brett Stahlman

>
> I try to hightlight a sentence as yellow. To do this, I press \i
> followed by ky. But instead of a yellow bgColor, I get this symbol:
>

> �

Michael Maurer

unread,
Jan 4, 2010, 12:29:43 PM1/4/10
to vim...@googlegroups.com

Thanks Brett, works like a charm. I turned off some colors and I think
I notice a slight decrease in start-up time. Great 2.0, by the way!

Cheers,
Michael

Brett Stahlman

unread,
Jan 4, 2010, 1:37:54 PM1/4/10
to vim_use

On Jan 4, 11:29 am, Michael Maurer <salogynso...@gmail.com> wrote:
> On Mon, Jan 4, 2010 at 2:42 PM, Stahlman Family
>
>

... snip...

>
> > One final note: for performance reasons, I would recommend activating
> > only the colors you plan to use. If you decide later that you want more,
> > you can always activate them at that time without adversely affecting an
> > existing file. As explained in the help, the number of colors activated
> > has a significant impact on the number of syntax regions created, which
> > in turn impacts the speed of syntax highlighting redraw...
>
> > :help txtfmt-performance-considerations
>
> Thanks Brett, works like a charm. I turned off some colors and I think
> I notice a slight decrease in start-up time. Great 2.0, by the way!

Michael,
Excellent! Glad to hear it. I appreciate the positive feedback.

A lot of users could probably benefit from disabling a few rarely-used
colors. White and black, for instance, are probably not very useful
with the default colorscheme on a white background: the former because
it doesn't show up well, the latter because it's redundant with the
default text color. Alternatively, the user who finds that the default
color definitions are sub-optimal for his chosen colorscheme can
always use the txtfmtColor{} and txtfmtBgcolor{} arrays to redefine
any or all of the 8 available colors. The color definition syntax
permits the colors to be defined differently for cterm and gui.

:help txtfmtColor{}
:help txtfmtBgcolor{}
:help txtfmt-color-config

For users who routinely use several different colorschemes and want to
optimize their Txtfmt color definitions for each, I outline a strategy
in the help file whereby the color configuration options can be set
automatically as a function of the colorscheme in effect when a Txtfmt
buffer is loaded.

:help txtfmt-colorschemes

I'm glad you like 2.0. I'm currently working on what will most likely
be released as 3.0. The main feature it adds is visual maps to
facilitate adding and removing tokens for the visually selected
region.

Please don't hesitate to ask any more questions you may have...

Thanks,
Brett Stahlman

>
> Cheers,
> Michael- Hide quoted text -
>
> - Show quoted text -

Michael Maurer

unread,
Jan 6, 2010, 5:03:57 AM1/6/10
to vim...@googlegroups.com
On Mon, Jan 4, 2010 at 7:37 PM, Brett Stahlman
<bretts...@comcast.net> wrote:
..snip

>
> Please don't hesitate to ask any more questions you may have...
>
> Thanks,
> Brett Stahlman

Another thing I just noticed that might be of importance to
non-english keyboard-layouts:

You recommend pressing <CTRL-\><CTRL-\> in quick succession to
terminate the formatted area (while in insert mode). On german
keyboards, \ can only be typed by pressing ALT+ß, so for
<CTRL-\><CTRL-\> I would have to press <CTRL-ALT-ß><CTRL-ALT-ß>. This
doesn't seem to work. I tried it different ways, but no luck.

I just get

\\

It might be something in my gvimrc that's blocking it though. I'm not
excluding the possibility that my config/setup is the culprit.

- Michael

Brett Stahlman

unread,
Jan 6, 2010, 12:09:29 PM1/6/10
to vim_use

On Jan 6, 4:03 am, Michael Maurer <salogynso...@gmail.com> wrote:


> On Mon, Jan 4, 2010 at 7:37 PM, Brett Stahlman<brettstahl...@comcast.net> wrote:
>
> ..snip
>
>
>
> > Please don't hesitate to ask any more questions you may have...
>
> > Thanks,
> > Brett Stahlman
>
> Another thing I just noticed that might be of importance to
> non-english keyboard-layouts:
>
> You recommend pressing <CTRL-\><CTRL-\> in quick succession to
> terminate the formatted area (while in insert mode). On german
> keyboards, \ can only be typed by pressing ALT+ß, so for
> <CTRL-\><CTRL-\> I would have to press <CTRL-ALT-ß><CTRL-ALT-ß>. This
> doesn't seem to work. I tried it different ways, but no luck.

Michael,
Txtfmt provides a flexible method for customizing map key sequences.

To demonstrate with a simple example, you could change the default...
<C-\><C-\>
...to...
<C-_>
...with the following line in your .vimrc:
imap <C-_> <Plug>TxtfmtInsertTok_i

In addition to helping with non-English keyboards, this can also can
prove useful when the Txtfmt default conflicts with maps defined by
other plugins.

For more details on map customization...
:help txtfmt-map-config

To see a listing of all insert-token mappings that can be
customized...
:help txtfmt-ins-tok-map-list

The same customization capability is available for other types of maps
as well (e.g., txtfmt-jump-to-tok-maps).

Hope this helps...
Brett Stahlman

>
> I just get
>
> \\
>
> It might be something in my gvimrc that's blocking it though. I'm not
> excluding the possibility that my config/setup is the culprit.
>
> - Michael
>
> --

> Du bist meine kleine Gummizellehttp://michaelmaurer.net/archives/2009/11/14/du_bist_meine_kleine_gum...

Stahlman Family

unread,
Jan 7, 2010, 8:34:25 AM1/7/10
to vim...@googlegroups.com

Michael Maurer wrote:
> On Mon, Jan 4, 2010 at 7:37 PM, Brett Stahlman
> <bretts...@comcast.net> wrote:
> ..snip
>> Please don't hesitate to ask any more questions you may have...
>>
>> Thanks,
>> Brett Stahlman
>
> Another thing I just noticed that might be of importance to
> non-english keyboard-layouts:
>
> You recommend pressing <CTRL-\><CTRL-\> in quick succession to
> terminate the formatted area (while in insert mode). On german
> keyboards, \ can only be typed by pressing ALT+ß, so for
> <CTRL-\><CTRL-\> I would have to press <CTRL-ALT-ß><CTRL-ALT-ß>. This
> doesn't seem to work. I tried it different ways, but no luck.
>
> I just get
>
> \\

Michael,
Although you may wish to customize the map sequence (as described in my
previous post) simply because Ctrl-Alt-ß is harder to type than Ctrl-\,
I'm wondering whether there could be something odd with your setup, as I
don't see this issue when I switch to a German keyboard layout. For me,
typing the sequence you described in insert mode brings up the "Enter a
fmt / clr string" prompt, just as <C-\><C-\> does on my US keyboard layout.

I'm wondering whether the <C-\><C-\> map is even defined for you. Does
:imap in a Txtfmt buffer display something like the following?
i <C-\><C-\> @<Plug>TxtfmtInsertTok_i

The only thing I know of that could prevent the map from being defined
is a conflict or ambiguity with a mapping defined by another plugin, but
even then, unless you've altered the default setting of the
txtfmtMapwarn option, the Txtfmt mapping will be defined anyway.

Brett Stahlman

Michael Maurer

unread,
Jan 13, 2010, 5:48:24 AM1/13/10
to vim...@googlegroups.com
On Thu, Jan 7, 2010 at 2:34 PM, Stahlman Family
<bretts...@comcast.net> wrote:
> Michael,
> Although you may wish to customize the map sequence (as described in my
> previous post) simply because Ctrl-Alt-ß is harder to type than Ctrl-\, I'm
> wondering whether there could be something odd with your setup, as I don't
> see this issue when I switch to a German keyboard layout. For me, typing the
> sequence you described in insert mode brings up the "Enter a fmt / clr
> string" prompt, just as <C-\><C-\> does on my US keyboard layout.
>
> I'm wondering whether the <C-\><C-\> map is even defined for you. Does :imap
> in a Txtfmt buffer display something like the following?
> i  <C-\><C-\>   @<Plug>TxtfmtInsertTok_i
>
> The only thing I know of that could prevent the map from being defined is a
> conflict or ambiguity with a mapping defined by another plugin, but even
> then, unless you've altered the default setting of the txtfmtMapwarn option,
> the Txtfmt mapping will be defined anyway.
>
> Brett Stahlman

No, you're right, <C-\><C-\> is not defined. Plus I've discovered some
other irregularities. In one document, typing Ä will result in
switching the format of the text to italics. I'm thinking that there's
probably an open formatting tag somewhere, but I haven't found it yet.
In addition, I have a couple of plugins installed, not sure which one
is responsible. I guess I'll try switching them off one by one and see
if the problem persists.

Thanks for the support,
Michael

Stahlman Family

unread,
Jan 13, 2010, 8:52:05 AM1/13/10
to vim...@googlegroups.com

Michael Maurer wrote:
> On Thu, Jan 7, 2010 at 2:34 PM, Stahlman Family
> <bretts...@comcast.net> wrote:
>> Michael,
>> Although you may wish to customize the map sequence (as described in my
>> previous post) simply because Ctrl-Alt-ß is harder to type than Ctrl-\, I'm
>> wondering whether there could be something odd with your setup, as I don't
>> see this issue when I switch to a German keyboard layout. For me, typing the
>> sequence you described in insert mode brings up the "Enter a fmt / clr
>> string" prompt, just as <C-\><C-\> does on my US keyboard layout.
>>
>> I'm wondering whether the <C-\><C-\> map is even defined for you. Does :imap
>> in a Txtfmt buffer display something like the following?
>> i <C-\><C-\> @<Plug>TxtfmtInsertTok_i
>>
>> The only thing I know of that could prevent the map from being defined is a
>> conflict or ambiguity with a mapping defined by another plugin, but even
>> then, unless you've altered the default setting of the txtfmtMapwarn option,
>> the Txtfmt mapping will be defined anyway.
>>
>> Brett Stahlman
>
> No, you're right, <C-\><C-\> is not defined. Plus I've discovered some
> other irregularities. In one document, typing Ä will result in
> switching the format of the text to italics.

Hmmm... I have an idea what's happening there, at least... The character
code for Ä is 196. Recall that the Txtfmt "tokens" that control
highlighting are simply characters in the buffer, which are interpreted
specially by the Txtfmt syntax. By default (if you don't override the
tokrange option), Txtfmt locates the token range at a character code
determined by 'encoding'. Ideally, the tokens would always go in the
Unicode "Private Use Area", which begins at 0xE000 and is guaranteed
never to be used for any standardized purpose. Of course, this ideal
location is possible only if you're using a Unicode encoding (e.g.,
utf-8). If you're using latin1, the Txtfmt tokens will need to fit
within a single byte, so there aren't as many choices of unused
characters. The default is to locate the tokens beginning at 180.
Unfortunately, as mentioned in the help, this is not ideal for
non-English users who often use character codes above 180 for text! This
default token location would make Ä (196) the "italic-underline" token.
To see whether this is the case, you can run :ShowTokenMap in the buffer
in question.

:help txtfmt-choosing-token-range
:help :ShowTokenMap

The bottom-line is, if you're using Unicode, tokens should be located in
the "Private Use Area" automatically, unless you have used the tokrange
option to specify a different location (e.g., in your .vimrc or in a
file's Txtfmt modeline).
Note: You can set the txtfmtTokrange option to an *expression* instead
of a literal value. This could be useful if you use both utf-8 and
latin1 at different times. The help gives the following example...

let g:txtfmtTokrange = '&enc == "utf-8" ? "0xE000X" : "180X"'

...which causes the tokens to be located at 0xE000 if encoding is utf-8
and at 180 otherwise. Personally, I prefer associating the tokrange
option with the file itself by putting the setting in a Txtfmt modeline:
e.g.,
vim:ft=txtfmt
txtfmt:tokrange=0xE000X

...but then, I always use Unicode...

:help txtfmtTokrange
:help txtfmt-'tokrange'-expr

If you have to use a non-Unicode encoding and you find a better place to
locate the Txtfmt tokens than 180, you can use the :MoveStartTok command
to translate all the tokens in an existing buffer to the new range.

:help :MoveStartTok

The :MakeTestPage command might aid you in finding that better location,
since it creates a modifiable test buffer using the settings specified
on the command line: e.g.,
:MakeTestPage tokrange=170X
:MakeTestPage tokrange=130S
.
.

:help :MakeTestPage

Note that if you wish to reduce the number of tokens required by Txtfmt,
you can always use "short" formats (180S, 0xE000S, etc...) instead of
"extended" formats (180X, 0xE000X, etc...) or "long" formats (180L,
0xE000L, etc...). The difference is that the short configuration
supports only foreground colors, whereas extended supports both
foreground and background colors. Long formats is the only one with
support for standout, reverse and undercurl attributes, but note that
for performance reasons, long formats are mutually exclusive with
background colors. There's a useful chart illustrating the effects of
the various "formats" suffixes in the help for the txtfmtTokrange
option. A separate chart in the section on short/long/extended formats
shows how many character codes are required for each configuration.

:help 'short'/'long'-formats

Sorry to bombard you with so much information. Let me know if anything
is unclear...

Thanks,
Brett Stahlman

Reply all
Reply to author
Forward
0 new messages