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 6824361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:53:32+00:00 2026-05-26T21:53:32+00:00

Inside a function I use to initialise some TeX related settings I have the

  • 0

Inside a function I use to initialise some TeX related settings I have the following mapping defined:

vmap <buffer> ucm :s/^\% //<CR>:nohlsearch<CR>

I expected it to allow me to easily uncomment visually selected lines. The analogous:

vmap <buffer> cm :s/^/\% /<CR>:nohlsearch<CR>

does a pretty nice job in commenting. Also analogous mappings for other languages, which use a #, and not a % work just fine. Those last ones look like this:

vmap <buffer> cm :s/^/# /<CR>:nohlsearch<CR>
vmap <buffer> ucm :s/^# //<CR>:nohlsearch<CR>

A sequence of V10jcmV10kucm is supposed to leave the code intact.

So now: What am I doing wrong?

  • 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-05-26T21:53:33+00:00Added an answer on May 26, 2026 at 9:53 pm

    You are adding unecessary stuff.

    :s/^/% <CR>
    

    and

    :s/^% /<CR>
    

    should work for commenting and uncommenting respectively.

    The third / is used to add options such as /c for “confirm” or /g for “global”. If you don’t use those options you don’t need this / at all.

    In your “uncomment” substitution you are escaping % but % in itself has no special meaning for Vim’s regex flavour. Not only Vim is certainly not going to match it if it’s escaped but \%<something> is used for a bunch of atoms like \%d. So your pattern fails because Vim stumbles upon your \% expecting the rest of the atom and getting “nothing”.

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

Sidebar

Related Questions

I need to use a function inside of another function, how can I do
How do I create or use a global variable inside a function? How do
I'm trying to use CallFunction() to call a function inside a flash file, but
I'm trying to use usort() and leverage a global variable inside its function scope,
I want to use magic function __set() and __get() for storing SQL data inside
Can someone explain to me why I cannot use document.getElementById('id').value inside of a function?
I have a function inside a class that returns a reference to a member
I thought up a good use of the static keyword inside a function to
I have a repository class that defines some basic Get/Save/Delete methods. Inside these, I
I have a HtmlView inside my MFC program where I display some data in

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.