Vim-주석 문자가있는 서라운드 주석 라인 것을 깨달았습니다. #################### # Helper Functions # #################### 그러나 그것은 지루합니다.

오늘 나는 종종 코드에서 섹션을 다음과 같이 정의하고 싶다는 것을 깨달았습니다.

####################
# Helper Functions #
####################

그러나 그것은 지루합니다. 다음과 같은 줄이 있다고 가정합니다.

# Helper Functions #

vim키를 짧게 감싸는 키 스트로크 는 무엇입니까 #? Shift는 이 도전에서 키 스트로크로 계산 되지 않습니다 .

테스트 사례 :

Input: "#test test test#"
Output:
################
#test test test#
################

Input: "#this is a nice block comment#"
Output:
##############################
#this is a nice block comment#
##############################

Input: "# s p a c e s must be supported a l s o#"
Output:
########################################
# s p a c e s must be supported a l s o#
########################################



답변

11 8 7 키 스트로크

YpVkr#p

Yp - duplicate current line, leaving the cursor at the lower of the two
V - enter visual line mode
k - go up and select both lines
r# - replace every selected character with #. Leaves visual mode and leaves cursor at the upper line.
p - put the yanked line (the original) on the next line.

(Y = yy를 상기시켜 준 손잡이에 감사)


답변

16 15 14 키 스트로크

Yp
:s/./#/g
<cr>
YkP

간단한 접근 방식 : 줄을 복제하고 모든 문자를로 바꾸고 #결과를 복사하여 위에 붙여 넣습니다.

나는 + 와 +에 대해 두 개 대신 각각 하나의 키 입력으로 계산 P하고 있습니다. 즉, 질문은 “명령”을 계산하도록 지정하는데, 여기서 대체 계산 방법을 잘 모르겠습니다.:ShiftpShift;


답변