Howto change selected text's color background ?

838 views
Skip to first unread message

jackm

unread,
Dec 10, 2008, 5:31:37 AM12/10/08
to vim...@googlegroups.com

Hi all :-) ,
Howto change color background of selected text :confused:
Thanx
--
View this message in context: http://www.nabble.com/Howto-change-selected-text%27s-color-background---tp20932166p20932166.html
Sent from the Vim - General mailing list archive at Nabble.com.

jack

unread,
Dec 10, 2008, 5:40:17 AM12/10/08
to vim_use
Hi all ,
Howto change color background of selected text
Thanx

Efraim Yawitz

unread,
Dec 10, 2008, 5:56:59 AM12/10/08
to vim...@googlegroups.com
:hi Visual

Albie

unread,
Dec 10, 2008, 6:12:50 AM12/10/08
to vim...@googlegroups.com
jackm wrote:
> Hi all :-) ,
> Howto change color background of selected text :confused:
> Thanx
>

The currently selected colorscheme determines what colours are used for
various different areas of text (highlighting groups). To see which
colorscheme you are using, type
:echo g:colors_name

To override your colorscheme, it would probably work best to copy your
preferred <colorscheme>.vim file to your
~/.vim/colors/MyColorScheme.vim, change that file according to your
preferences and then source this file in your g/vimrc, using the command
colorscheme MyColorScheme

The selection colour is determined by the "Visual" highlighting group.
To change this once-off to a white foreground on a black background, use
the following command:
:highlight visual guifg=#ffffff guibg=#000000

For more info, see
:h coloring
:h highlight-term
:h highlight

--

[ Albie Janse van Rensburg ~ http://morph.telspace.co.za ]

A lie is an abomination unto the Lord and a very present help in time of
trouble.
-- Adlai Stevenson

jack

unread,
Dec 10, 2008, 8:29:33 AM12/10/08
to vim_use
sorry gays for my misleading request,
what i want is how to change the background colors of some lines

On Dec 10, 12:12 pm, Albie <albie....@gmail.com> wrote:
> jackm wrote:
> > Hi all :-) ,
> > Howto change color background of selected text :confused:
> > Thanx
>
> The currently selected colorscheme determines what colours are used for
> various different areas of text (highlighting groups).   To see which
> colorscheme you are using, type
>     :echo g:colors_name
>
> To override your colorscheme, it would probably work best to copy your
> preferred <colorscheme>.vim file to your
> ~/.vim/colors/MyColorScheme.vim, change that file according to your
> preferences and then source this file in your g/vimrc, using the command
>     colorscheme MyColorScheme
>
> The selection colour is determined by the "Visual" highlighting group.
> To change this once-off to a white foreground on a black background, use
> the following command:
>     :highlight visual guifg=#ffffff guibg=#000000
>
> For more info, see
>     :h coloring
>     :h highlight-term
>     :h highlight
>
> --
>
> [ Albie Janse van Rensburg ~http://morph.telspace.co.za]

fritzophrenic

unread,
Dec 10, 2008, 10:20:10 AM12/10/08
to vim_use


On Dec 10, 7:29 am, jack <jack.mort...@gmail.com> wrote:
> sorry gays for my misleading request,
> what i want is how to change the background colors of some lines
>

Vim is not really meant to do that kind of thing...it's a text editor,
not a word processor or WSIWYG publication platform.

However, there are a few ways.

One way is using the txtfmt plugin: http://www.vim.org/scripts/script.php?script_id=2208

Another way is to use :match, :2match, :3match, or matchadd().
See :help :match, :help matchadd(). This way will not be permanent in
any way, shape, or form.

A final way would be to define syntax highlighting rules, but I don't
think that's what you want. These are usually associated with file
type.

Note that, even using txtfmt, the colors will only show up in Vim, or
if you use the 2html feature. I believe this is discussed in the
txtfmt documentation (though I don't use it at all, so I could be
wrong).

Matt Wozniski

unread,
Dec 11, 2008, 3:49:59 AM12/11/08
to vim...@googlegroups.com
On Wed, Dec 10, 2008 at 10:20 AM, fritzophrenic wrote:

>
> On Dec 10, 7:29 am, jack wrote:
>>
>> sorry gays for my misleading request,
>> what i want is how to change the background colors of some lines
>
> Vim is not really meant to do that kind of thing...it's a text editor,
> not a word processor or WSIWYG publication platform.
>
> However, there are a few ways.
>
> One way is using the txtfmt plugin: http://www.vim.org/scripts/script.php?script_id=2208
>
> Another way is to use :match, :2match, :3match, or matchadd().
> See :help :match, :help matchadd(). This way will not be permanent in
> any way, shape, or form.

I wrote a plugin that wraps this method when someone on #vim asked for
this very thing, once upon a time. It's never been terribly useful to
me, but I can see how someone might want it, once in a while...

http://www.vim.org/scripts/script.php?script_id=2028

> A final way would be to define syntax highlighting rules, but I don't
> think that's what you want. These are usually associated with file
> type.
>
> Note that, even using txtfmt, the colors will only show up in Vim, or
> if you use the 2html feature. I believe this is discussed in the
> txtfmt documentation (though I don't use it at all, so I could be
> wrong).

~Matt

Stahlman Family

unread,
Dec 11, 2008, 7:55:59 AM12/11/08
to vim...@googlegroups.com
Yes. Txtfmt lets you highlight your plain text documents with 8 colors
and either 3 or 6 format attributes (bold, underline, italic, and if
"long" format mode is used, standout, reverse and undercurl as well).
Caveat: Currently, only foreground text color may be set with Txtfmt.
I've been intrigued by the possibility of adding background color to the
mix. I believe doing so is possible, and may also be feasible, provided
that "short" formats are used (bold, underline, italic only). The reason
for this restriction is that with "long" formats, the number of syntax
regions processed by Vim might become prohibitively large. (If you doubt
this, do a :syntax command in a txtfmt buffer using "long" formats and
then be prepared to hit the space bar a lot of times.) At any rate, I'll
have to do some prototyping when I get some time...

Brett Stahlman
> >
>

Stahlman Family

unread,
Nov 9, 2009, 8:57:36 AM11/9/09
to vim...@googlegroups.com


Stahlman Family wrote:
>
>
> fritzophrenic wrote:
>>
>> On Dec 10, 7:29 am, jack <jack.mort...@gmail.com> wrote:
>>> sorry gays for my misleading request,
>>> what i want is how to change the background colors of some lines
>>>
>> Vim is not really meant to do that kind of thing...it's a text editor,
>> not a word processor or WSIWYG publication platform.
>>
>> However, there are a few ways.
>>
>> One way is using the txtfmt plugin: http://www.vim.org/scripts/script.php?script_id=2208

.
.
.

> Yes. Txtfmt lets you highlight your plain text documents with 8 colors
> and either 3 or 6 format attributes (bold, underline, italic, and if
> "long" format mode is used, standout, reverse and undercurl as well).
> Caveat: Currently, only foreground text color may be set with Txtfmt.
> I've been intrigued by the possibility of adding background color to the
> mix. I believe doing so is possible, and may also be feasible, provided
> that "short" formats are used (bold, underline, italic only). The reason
> for this restriction is that with "long" formats, the number of syntax
> regions processed by Vim might become prohibitively large. (If you doubt
> this, do a :syntax command in a txtfmt buffer using "long" formats and
> then be prepared to hit the space bar a lot of times.) At any rate, I'll
> have to do some prototyping when I get some time...

Just noticed I never posted a follow-up to this after adding the
requested support for background color to the Txtfmt plugin:

http://www.vim.org/scripts/script.php?script_id=2208

As of version 2.0, Txtfmt lets you alter not only a text region's
foreground color and format attributes (bold, italic, underline,
etc...), but also its background color (as requested by the original
poster). Actually, the subject line specifies the ability to change the
background color of the "selected text". Visual maps and menu commands
for altering the highlighting of the visual selection are the focus of
current development...

Brett Stahlman

>
> Brett Stahlman
>
> >
>

Reply all
Reply to author
Forward
0 new messages