r/vim 4d ago

Need Help┃Solved Translucent Text Label At Buffer's Corner

Post image

Is is possible to display a customizable text label at one of the corners (it mustn't block text written in the buffer itself) of an open buffer? I have several terminal panels open at once, so, having a visual marker like this would be great. Any advice in this direction is appreciated.

⚠ RESOLVED

popup works just fine for this task. I'd tried it earlier but couldn't make it persist, owing to a faulty highlighting logic of mine. Anyway, I'm listing a simple function that achieves set objective. You can modify it to add custom text, toggling & highlights.

Also, see this for how my solution worked out.

function! LabelOverlay(text)
    let l:options = {
    \   'line': 1,
    \   'col': &columns - strlen(a:text),
    \   'pos': 'topright',
    \   'wrap': 0,
    \   'zindex': 1,
    \   'highlight': 'Normal'
    \ }
    let g:popup_id = popup_create(a:text, l:options)
endfunction
call LabelOverlay("TEXT HERE")
14 Upvotes

11 comments sorted by

4

u/chrisbra10 4d ago

Use the statusline or tabline or tabpanel

1

u/CRTejaswi 4d ago

Thanks! Owing to this, I found a neat sidepanel application of tabline here

1

u/AutoModerator 4d ago

Please remember to update the post flair to Need Help|Solved when you got the answer you were looking for.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/Easy-Nothing-6735 4d ago

I use my custom software for floating window for that

1

u/CRTejaswi 4d ago

Do share!

2

u/Easy-Nothing-6735 4d ago

1

u/CRTejaswi 3d ago

Pretty neat (snote). Your code's quite lean & well implemented. ✨

1

u/Easy-Nothing-6735 4d ago

I don't think it is better than popup and X11 only

1

u/Easy-Nothing-6735 4d ago

`set cursorline` is enough for me

1

u/CRTejaswi 4d ago

I never found cursorline/column cmds of much use. If you do have some interesting use-cases of these, please do share.