Microsoft MVP성태의 닷넷 이야기
VS.NET IDE: 96. Visual Studio에서 /* ~ */ 주석을 위한 단축키(매크로) [링크 복사], [링크+제목 복사],
조회: 24775
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

Visual Studio에서 /* ~ */ 주석을 위한 단축키(매크로)

다음과 같은 질문이 있습니다.

C#에서 범위로 주석을 다는 /* ~ */종류의 주석은 따로 단축키가 유무 문의 드립니다? 보이지가 않습니다.
; https://social.msdn.microsoft.com/Forums/ko-KR/18d2922d-e452-4376-822a-dc4df3c6b12e/c-?forum=dotnetko

예전에도 한번 이와 유사한 질문을 받았던 기억이 나는데... 그래서 이참에 아예 글로 정리해 봅니다.

일단, 현재 Visual Studio의 공식 단축키는 없습니다. 대신 매크로를 이용하시면 됩니다. Visual Studio 2012 이상의 환경에서 매크로 사용법은 다음의 글에 정리해 두었으니 참고하시고,

Visual Studio 2012/2013에서의 매크로 구현 - Visual Commander
; https://www.sysnet.pe.kr/2/0/1767

Macros for Visual Studio 2013
; https://www.sysnet.pe.kr/2/0/1817

여기서는 간단하게 Visual Studio 2013에서 "Macros for Visual Studio 2013" 도구로 구현하는 방법을 살펴보겠습니다.

가장 중요한 매크로 구현 코드는 다음과 같습니다.

if (dte.ActiveDocument == null) {
}
else {
    var selection = dte.ActiveDocument.Selection;
    selection.Mode = 0;

    var startPoint = selection.BottomPoint.CreateEditPoint();
    var endPoint = selection.TopPoint.CreateEditPoint();

    var firstPos = endPoint.AbsoluteCharOffset;

    var text = selection.Text;
    var startPos = text.indexOf("/*");

    dte.UndoContext.Open("SetCommentArea");
    try {
        if (startPos != -1) {
            text = text.replace(/\/\*/g, "");
            text = text.replace(/\*\//g, "");
            endPoint.ReplaceText(startPoint, text, 1);
        }
        else {
            endPoint.ReplaceText(startPoint, "/*" + text + "*/", 1);
            var lastPos = selection.BottomPoint.AbsoluteCharOffset;
            selection.MoveToAbsoluteOffset(firstPos, false);
            selection.MoveToAbsoluteOffset(lastPos, true);
        }
    }
    finally
    {
        dte.UndoContext.Close();
    }
}

제 경우에 이 매크로의 이름을 "ToggleComment"라고 했으며, "Macros for Visual Studio 2013" 도구에서는 단축키를 Ctrl + M, 1 부터 Ctrl + M, 9까지 할당할 수 있으니 원하는 것을 쓰시면 됩니다. (참고로, 좀 더 자유로운 단축키를 원하신다면 "Visual Commander" 도구를 사용해야 합니다.)

이 정도면... 그런대로~~~! ^^




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 7/10/2021]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 16  17  18  19  20  21  22  23  [24]  25  26  27  28  29  30  ...
NoWriterDateCnt.TitleFile(s)
13040정성태4/27/20227424VC++: 156. 비주얼 스튜디오 - Linux C/C++ 프로젝트에서 openssl 링크하는 방법
13039정성태4/27/20228256.NET Framework: 1999. C# - Playwright를 이용한 간단한 브라우저 제어 실습
13038정성태4/26/20226019오류 유형: 806. twine 실행 시 ConfigParser.ParsingError: File contains parsing errors: /root/.pypirc
13037정성태4/25/20226452.NET Framework: 1998. Azure Functions를 사용한 간단한 실습
13036정성태4/24/20227236.NET Framework: 1997. C# - nano 시간을 가져오는 방법 [2]
13035정성태4/22/20227798Windows: 204. Windows 10부터 바뀐 QueryPerformanceFrequency, QueryPerformanceCounter
13034정성태4/21/20227128.NET Framework: 1996. C# XingAPI - 주식 종목에 따른 PBR, PER, ROE, ROA 구하는 방법(t3320, t8430 예제)파일 다운로드1
13033정성태4/18/20227712.NET Framework: 1195. C# - Thread.Yield와 Thread.Sleep(0)의 차이점(?)
13032정성태4/17/20227434오류 유형: 805. Github의 50MB 파일 크기 제한 - warning: GH001: Large files detected. You may want to try Git Large File Storage
13031정성태4/15/20227030.NET Framework: 1194. C# - IdealProcessor와 ProcessorAffinity의 차이점
13030정성태4/15/20226636오류 유형: 804. 정규 표현식 오류 - Quantifier {x,y} following nothing.
13029정성태4/14/20227049Windows: 203. iisreset 후에도 이전에 설정한 전역 환경 변수가 w3wp.exe에 적용되는 문제
13028정성태4/13/20226999.NET Framework: 1193. (appsettings.json처럼) web.config의 Debug/Release에 따른 설정 적용
13027정성태4/12/20227256.NET Framework: 1192. C# - 환경 변수의 변화를 알리는 WM_SETTINGCHANGE Win32 메시지 사용법파일 다운로드1
13026정성태4/11/20228798.NET Framework: 1191. C 언어로 작성된 FFmpeg Examples의 C# 포팅 전체 소스 코드 [3]
13025정성태4/11/20228122.NET Framework: 1190. C# - ffmpeg(FFmpeg.AutoGen)를 이용한 vaapi_encode.c, vaapi_transcode.c 예제 포팅
13024정성태4/7/20226602.NET Framework: 1189. C# - 런타임 환경에 따라 달라진 AppDomain.GetCurrentThreadId 메서드
13023정성태4/6/20226911.NET Framework: 1188. C# - ffmpeg(FFmpeg.AutoGen)를 이용한 transcoding.c 예제 포팅 [3]
13022정성태3/31/20226857Windows: 202. 윈도우 11 업그레이드 - "PC Health Check"를 통과했지만 여전히 업그레이드가 안 되는 경우 해결책
13021정성태3/31/20227033Windows: 201. Windows - INF 파일을 이용한 장치 제거 방법
13020정성태3/30/20226791.NET Framework: 1187. RDP 접속 시 WPF UserControl의 Unloaded 이벤트 발생파일 다운로드1
13019정성태3/30/20226769.NET Framework: 1186. Win32 Message를 Code로부터 메시지 이름 자체를 구하고 싶다면?파일 다운로드1
13018정성태3/29/20227283.NET Framework: 1185. C# - Unsafe.AsPointer가 반환한 포인터는 pinning 상태일까요? [5]
13017정성태3/28/20227062.NET Framework: 1184. C# - GC Heap에 위치한 참조 개체의 주소를 알아내는 방법 - 두 번째 이야기 [3]
13016정성태3/27/20227999.NET Framework: 1183. C# 11에 추가된 ref 필드의 (우회) 구현 방법파일 다운로드1
13015정성태3/26/20229250.NET Framework: 1182. C# 11 - ref struct에 ref 필드를 허용 [1]
... 16  17  18  19  20  21  22  23  [24]  25  26  27  28  29  30  ...