Is there a shortcut in postman to comment a line?
Asked Answered
U

6

11

I am looking the Postman Shortcut panel but I don't see a shortcut to comment part of my code in a request body, it is very annoying to copy and paste <!-- comment--> to make a comment.

Ululant answered 20/8, 2017 at 21:42 Comment(0)
U
29

According to the shortcut panel Ctrl + / open the shortcut panel but I accidentally did it in the request body and it comments the line

Ululant answered 20/8, 2017 at 21:46 Comment(1)
I think it depends on the keyboard layout. Just to complement the answer, in my layout worked with Ctrl + ~Sculpture
E
9

For the Body, raw category, you can use the following:

  • Ctrl + k + c (Will comment your selection)
  • Ctrl + k + u (Will un-comment your selection but also Uppercase everything)

I did not found other way to uncomment than deleting all the // bars by hand

I also found a nice work around on this link https://www.youtube.com/watch?v=bX4-cLPcD2Q

This was a Feature Request to the PostMan team. 21 days ago someone has added a comment asking exactly to revert a comment with Ctrl + K + U and also reporting the upper case issue. Let's hope they fix this soon. https://github.com/postmanlabs/postman-app-support/issues/3358

UPDATE The Post Team has fixed this issue so now you can use:

  • Ctrl + k + c (Will comment your selection)
  • Ctrl + k + u (Will un-comment your selection)

Even if the previous youtube trick is still valid, chances are it is not necessary anymore to create a pre-request script.

Esther answered 14/12, 2020 at 4:48 Comment(9)
in what version is it fixed ?Often
This is just straight up lies, it is not fixed, granted the comment thread is very long and hard to follow but I am on latest and the behavior is still upper casing.Rosana
@TommyHolman this wasn't a lie, I personally tested one PostMan v8.3.0 where it was fixed!! postman.com/downloads/release-notes Suddenly at the next release, they stripped that back again. Do yourself a favour and ask them to fix it as my attempt just survive for one release!Esther
You should Edit your answer so that future people coming here can see the whole story and know they accidentally broke it again.Rosana
This is uncommenting and also turning all letters to uppercase!Pictograph
A workaround for the annoying uppercasing when you use Ctrl + K + U is to do Ctrl + H (replace command) then just replace all // with an empty string.Urbano
This is very frustrating. Here is the open issue if you want to track it and see if it is resolved in the future. BUT, the issue does provide a different shortcut of Ctrl + / that does work (at least on windows 11 and postman version 9+!Flimsy
@Rosana Can someone please tell me in which scenario it is desired to removed comments making THE TEXT SHOUT at oneself? Any. Ever. Past, current and future. Including obscure and surrealistic. I'm so filled with unhappy thoughts right now...Antimagnetic
@Flimsy That issue will turn 3 years in a week... I don't feel the PostMan team takes that as a serious one. Which, ironically, is serious...Antimagnetic
P
7

I have tried in postman and the below worked form me.

ctrl + k + c (Comments the line)
ctrl + / (uncomments the line)

Predilection answered 19/12, 2022 at 17:36 Comment(2)
I can use [Ctrl]+[#] for both commenting and uncommenting lines without uppercasing. I'm using v10.12.0 with a German keyboard. [Ctrl]+[K]+[U] still results in uppercase.Tobe
For me [Ctrl]+[/] works for both commenting and uncommenting. Postman version: v10.15. [Ctrl]+[K]+[U] still results in uppercase.Porcelain
E
1

As of Postman version 9.31.0, if you select multiple rows Postman still makes uppercase whilst uncommenting, with the key combination: ctrl + k + u

Workaround 1: ctrl + ö shortcut works well with my TR keyboard, it should be ctrl + . with the EN keyboard.

Workaround 2: That does not happen with single-line uncommenting, but you need to repeat it for each line (a bit annoying)

Emmett answered 20/10, 2022 at 13:55 Comment(0)
E
0

Like it says above, if you add something like the below to your Pre-request Script tab, you can use either // or /* */ to comment out a line/section:

if(pm.request.body && pm.request.body.raw) pm.request.body.raw = pm.request.body.raw.replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,'');
Erinerina answered 28/3, 2023 at 13:37 Comment(0)
L
0

workaround

ctrl + k + c -> comment
ctrl + k + u -> uncomment and uppercase
ctrl + shift + u -> lowercase
Lashaunda answered 7/3 at 22:10 Comment(1)
Thank you for your interest in contributing to the Stack Overflow community. This question already has a few answers—including ones that have been validated by the community. Are you certain your approach hasn’t been given previously? (It seems very similar to other suggestions to me.) If so, it would be useful to explain how your approach is different, under what circumstances your approach might be preferred, and/or why you think the previous answers aren’t sufficient. Can you kindly edit your answer to offer an explanation?Revise

© 2022 - 2024 — McMap. All rights reserved.