0

Ultimate goal is using underlined text in VIM (with st terminal). At this point I cannot paste underlined text in the st terminal (or VIM with st terminal). And text from text files with an underline does not show with an underline in the st terminal (or VIM in st terminal).

I opened a topic about on Reddit: font_formatting_st_differs

But I think I/it became a bit stuck.

Today I saw that I can print text in the st terminal with an underline:

printf "\e[1;4m%s\e[0m\n" "test"

This works

Perhaps adding the underline through VIM could solve my problem. In VIM (with st terminal) I can add an underlined text. The following VIM command changes the text to underlined text:

:match Underlined /abc\|abc/

But after saving the file (and opening) the underline is gone.

Excuses for my low level of experience.


Update: Thanks for the replies.

  • Terminal versus vim: yes, I understand. Problem is not with VIM. Problem is with the st terminal. I was hoping for some sort of workaround, using the "Underlined" vim functionality.
  • Pager versus word processor: Both not. I am using underlined strings in my window manager. For this I have edited the config.h file. This cannot be done with a different file format. I added a screenshot of VIM with gnome-terminal and VIM with st.

Saving the file with abc underlined. Does not safe the file with abc underlined. I did try the AnsiEsc.vim plugin. But it does not work. Problem is not with the plugin I think, but with the fact that saving the file with abc underlined, does not safe the file with abc underlined.

config.h file in vim using gnome-terminal and st-terminal Text after saving

9
  • Thanks for the clarification :-) Jan 14, 2023 at 9:01
  • If the answer solve your problem maybe could you validate it using the green v button next to the arrow voting button. It let the answered question rest :-) If you expect another answer maybe could you give us more hint about what you expect and let the question open ;-) Jan 14, 2023 at 10:00
  • ok, Vivian, can you please confirm that changing the formatting with Underlined only affects the actual view? That this change can not be saved with the file (without changing the file type)?
    – Peter P.
    Jan 14, 2023 at 10:19
  • 1
    Sorry Vivian but this "How to paste underlined text from Vim to a console?" was really not my question. My question was if I remind correct "Save underlined text in VIM" Meaning how to save. I only care about the terminal because it's the interface for VIM. Also gnome-terminal does show the text underlined (st terminal not). What I want is that the file editor shows the text as it is: underlined. I changed my own question back to what it more or less was.
    – Peter P.
    Jan 14, 2023 at 11:07
  • 1
    I misunderstood. I have reverted the title. Always feel free to revert my change. I try to make the question more obvious to others such that they can benefit from the answers but I should not twist the original intention. Jan 14, 2023 at 11:16

1 Answer 1

0

I believe there is a misunderstanding. Vim is a pure text editor and not a word processor.

In word processor the underline is a characteristic of the text.

But in Vim it is not. The underline characteristic is determine by a rule defined from the file type.

In special text like the one output by less or more they include escape characters that can be used to format the surrounded text and be hided by Vim like in vim-plugin-AnsiEsc

The vim-markdown plugin is another example that will hide the _ characters (using the conceal feature) and underline the text surrounded by _ (using the syntax feature)

It is probably possible to write a Vim script that copy the underline characteristics from Vim to a word processor using a special clipboard format (e.g. rtf on Windows).

In the opposite direction you would have to make sure the clipboard contains marker characters that can be used by the filetype syntax to format the text accordingly.

Hope it help :-/

3
  • I think the OP is looking for a pager that undersdand ANSI/CSI escape sequences (more, less, most does, and vim is able to with AnsiEsc.vim for example) I agree, it defeat the purpose of a text editor ...or maybe OP isn't after a pager but a kinda word processor?
    – gildux
    Jan 14, 2023 at 2:33
  • Also note that with +terminal feature compiled, OP can do :term cat thedesiredfile Check those answers too: unix.stackexchange.com/a/638443/23889 and unix.stackexchange.com/a/585403/23889
    – gildux
    Jan 14, 2023 at 2:39
  • Going to bed I had the same idea :-) May could you publish an answer based on the answer you mentioned. Jan 14, 2023 at 6:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.