Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9177761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:23:56+00:00 2026-06-17T17:23:56+00:00

I have a mapping that I use to print the highlighting on a line.

  • 0

I have a mapping that I use to print the highlighting on a line. I got the idea from other posters here so thanks for that. Here’s what I do:

function! PrintSyntaxItem()
    let l:colorsyntax = synIDattr(synID(line("."), col("."), 0), "name")
    execute "highlight" l:colorsyntax
endfunction

and I map it like this:

nnoremap <A-s> :call PrintSyntaxItem()<CR>

However when I execute it, I get the command line echoed as well as the output that I want which leads to getting a “Press ENTER” prompt. I.e. in the output I see:

:execute "highlight" synIDattr(synID(line("."), col("."), 0), "name")
vimBracket     xxx links to Delimiter
Press ENTER or type command to continue

I’d like to lose the :execute line and then the Press ENTER line would go away as well. Is there any way to do this? If I put silent in front of the execute I still get that line printed out but lose the highlight output (as well as the Press ENTER prompt), but then to get back my desired output I just prefix it with unsilent and I get it but…

Basically I want to either suppress the echo of the :execute line or clear it after the fact but I’m not sure how to do either and trawling the docs for info on manipulating the messages hasn’t borne any fruit.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:23:58+00:00Added an answer on June 17, 2026 at 5:23 pm

    The press enter prompt comes up because the output of highlight takes up multiple lines. You could get rid of the extra line by redirecting the output, removing \n, and then echoing it:

    function! PrintSyntaxItem()
        let l:output = ''
        redir => l:output
        silent exec "hi" synIDattr(synID(line("."), col("."), 0), "name")
        redir END
        echo substitute(l:output, '\n', '', '')
    endfunction
    

    However, the xxx sample is no longer properly highlighted. Instead, you can hack the press enter prompt away by temporarily changing cmdheight:

    nnoremap <silent> <A-s> :set ch=2 \| exec "hi"
        \ synIDattr(synID(line("."), col("."), 0), "name") \| set ch=1<CR>
    

    This prevents the prompt from being printed in the first place by initially changing the command line height to 2, and then reverting it to 1 afterward in order to cut off the empty line. I did away with the function altogether, but you can of course call it between the set ch if you prefer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a mapping function that does this: public static void
I have a Hibernate mapping that looks something like this: <class name=MyEntity> <set name=scalarSet
Good Day, I have a Hibernate mapping that looks something like this: public class
I am using Struts 1.2.7 and have the standard servlet mapping that uses *.do
I have the following iBatis mapping for an Oracle Stored Procedure that returns a
I have two tables that are related via a mapping table: keywords titles I
I have a situation in which I'd like to maintain a mapping from one
I use JNA to call a c function from java. The function writes a
I have a mapping of String id -> Object . Apart from merely having
I have a fluent mapping of a domain class that defines the names for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.