리눅스의 nano 에디터 단축키

Linux에서 편집할 일이 있으면 저는 주로 nano를 사용하는 편입니다. 오래 전에 Vi 편집기에 관한 책을 구입하여 사용법을 익힌 적이 있지만 Linux를 한동안 사용하지 않게 되니까(사실 제대로 사용한 적은 한 번도 없지만) 머리 속에 남아 있는 것이 아무 것도 없네요.

아래는 nano 에디터를 사용할 때 참고할 수 있는 유용한 단축키 목록입니다. (출처: http://staffwww.fullcoll.edu/sedwards/Nano/UsefulNanoKeyCommands.html)

자세한 사용법을 원하는 경우 nano가 실행된 상태에서 Ctrl+g를 누르면 도움말이 표시됩니다.

리눅스의 nano 에디터 단축키 3
nano 도움말 화면

nano 도움말 화면에서는 전체 명령어/단축키 목록을 확인할 수 있습니다.

전체 단축키 (영문)

전체 키보드 단축키는 다음을 참고해보세요:

^ = Ctrl key M = Alt key

^G      (F1)            Display this help text
^X      (F2)            Close the current file buffer / Exit from nano
^O      (F3)            Write the current file to disk
^J      (F4)            Justify the current paragraph

^R      (F5)            Insert another file into the current one
^W      (F6)            Search for a string or a regular expression
^Y      (F7)            Move to the previous screen
^V      (F8)            Move to the next screen

^K      (F9)            Cut the current line and store it in the cutbuffer
^U      (F10)           Uncut from the cutbuffer into the current line
^C      (F11)           Display the position of the cursor
^T      (F12)           Invoke the spell checker, if available

^_      (F13)   (M-G)   Go to line and column number
^\      (F14)   (M-R)   Replace a string or a regular expression
^^      (F15)   (M-A)   Mark text at the cursor position
        (F16)   (M-W)   Repeat last search

M-^             (M-6)   Copy the current line and store it in the cutbuffer
M-}                     Indent the current line
M-{                     Unindent the current line

^F                      Move forward one character
^B                      Move back one character
^Space                  Move forward one word
M-Space                 Move back one word
^P                      Move to the previous line
^N                      Move to the next line

^A                      Move to the beginning of the current line
^E                      Move to the end of the current line
M-(             (M-9)   Move to the beginning of the current paragraph
M-)             (M-0)   Move to the end of the current paragraph
M-\             (M-|)   Move to the first line of the file
M-/             (M-?)   Move to the last line of the file

M-]                     Move to the matching bracket
M--             (M-_)   Scroll up one line without scrolling the cursor
M-+             (M-=)   Scroll down one line without scrolling the cursor

M-<             (M-,)   Switch to the previous file buffer
M->             (M-.)   Switch to the next file buffer

M-V                     Insert the next keystroke verbatim
^I                      Insert a tab at the cursor position
^M                      Insert a newline at the cursor position
^D                      Delete the character under the cursor
^H                      Delete the character to the left of the cursor
M-T                     Cut from the cursor position to the end of the file

M-J                     Justify the entire file
M-D                     Count the number of words, lines, and characters
^L                      Refresh (redraw) the current screen

M-X                     Help mode enable/disable
M-C                     Constant cursor position display enable/disable
M-O                     Use of one more line for editing enable/disable
M-S                     Smooth scrolling enable/disable
M-P                     Whitespace display enable/disable
M-Y                     Color syntax highlighting enable/disable

M-H                     Smart home key enable/disable
M-I                     Auto indent enable/disable
M-K                     Cut to end enable/disable
M-L                     Long line wrapping enable/disable
M-Q                     Conversion of typed tabs to spaces enable/disable

M-B                     Backup files enable/disable
M-F                     Multiple file buffers enable/disable
M-M                     Mouse support enable/disable
M-N                     No conversion from DOS/Mac format enable/disable
M-Z                     Suspension enable/disable

nano 단축키 (한글)

파일 관리

작업 단축키/명령어
nano 내에서 파일 열기 Ctrl+r

이 명령어를 입력하면 화면 아래에 새로운 메뉴 항목이 표시됩니다. 예를 들어, Ctrl+T를 누르면 파일 시스템을 탐색하여 파일을 찾아서 열 수 있습니다.

다음 파일 버퍼 표시 lt+>
이전 파일 버퍼 표시 Alt+<
현재 파일을 디스크에 저장 Ctrl+o
현재 파일 버퍼 종료 Ctrl+x

파일이 저장되지 않았다면 저장할 것인지 물어옵니다. 파일 버퍼가 하나만 열려 있는 경우 파일 버퍼를 종료하면 nano에서 나가게 됩니다.

복사 및 붙여넣기

작업 단축키/명령어

자르기 또는 붙여넣기 작업을 할 영역 선택

Alt+a

Alt+a로 마크를 설정한 후에 커서를 이동시켜 영역을 지정합니다. 커서를 움직일 때 하이라이트됩니다. 또한, 영역 지정을 취소하려면 Alt+a를 다시 누르면 됩니다.

강조 표시된 영역을 클립보드에 복사 Alt+^
강조 표시된 영역을 잘라서 클립보드에 저장 Ctrl+k

라인을 삭제(정확하게는 자르기)할 때에도 사용

클립보드의 내용을 현재 커서 위치에 붙여넣기 Ctrl+u
현재 커서 위치에서 라인의 끝(EOL)까지 자르기 Ctrl+k

이 명령어는 영역을 강조표시할 필요가 없습니다.

코드 탐색

작업 단축키/명령어
파일의 시작 부분으로 이동 Alt+\
파일의 끝으로 이동 Alt+/

한 화면 앞으로 이동(아래로 이동)

Ctrl+v
한 화면 뒤로 이동(위로 이동) Ctrl+y
대상 라인 번호로 이동(라인 번호를 입력하여 곧바로 이동) Alt+g
짝을 이루는 열린/닫힌 기호로 곧바로 이동 Alt+]

일치하지 않는 괄호(brace) 컴파일러 오류를 찾을 때 매우 유용

창 스크롤 Alt+= 아래로 스크롤

Alt+- 위로 스크롤

블록 들여쓰기/내어쓰기

Alt+a 를 사용하여 블록을 선택한 다음

  • Alt+} 선택한 블록 들여쓰기
  • Alt+{ 선택한 블록 내어쓰기

찾기 및 바꾸기

작업 단축키/명령어

대상 문자열 검색

Ctrl+w

이 명령어를 입력하면 화면 하단에 새로운 메뉴 항목이 표시됩니다. 예: Alt+B를 누르면 역방향 검색 전환, Ctrl+R:  검색 문자열을 다른 문자열로 바꾸기

마지막 검색 반복 Alt+w
다음 검색에 대한 방향 토글(전환) Ctrl+w를 누른 다음 Ctrl+b
찾아서 바꾸기 Alt+r

 

명명된 키에 해당하는 명령어

작업 단축키/명령어

Home

Ctrl+a
End Ctrl+e
Page Up Ctrl+y
Page Down Ctrl+v
화살표 키 Ctrl+f (오른쪽),
Ctrl+b
(왼쪽),
Ctrl+n
(아래),
Ctrl+p
(위)
Tab Ctrl+i
Backspace Ctrl+h
Delete Ctrl+d
Return Ctrl+m

참고

nano가 실행된 상태에서 Ctrl+g를 누르면 도움말이 표시됩니다.

nano에서 라인 번호를 표시하려면 파일을 열 때 -c를 추가합니다.

nano -c filename

또는, /etc/nanorc에서 # set const를 찾아서 주석 기호를 제거하면 항상 커서 위치의 라인 번호가 표시됩니다.

리눅스의 nano 에디터 단축키 4

하지만 왼쪽에 라인 번호를 표시하는 기능은 없다고 합니다.

일부 글에 제휴 링크가 포함될 수 있으며 파트너스 활동으로 일정액의 수수료를 받을 수 있습니다.

2개 댓글

  1. 예전에 해킨토시 초기에 쓸때 부트로더 조정하다가 커널 패닉 나면 프롬프트로 부팅해서 nano로 파일 수정하던때가 생각나네요

    지금은 해킨토시 부트로더랑 EFI 로더가 완전히 분리되어서 그 떄 같은 삽질은 안해도 되지만요 ㅋㅋㅋ

    1. Linux에 대한 글을 보면 대체적으로 Vim 에디터를 기준으로 많이 설명하는 것 같습니다.

      해킹토시도 시간이 되면 한 번 도전해보고 싶지만 엄두가 나지 않네요. 예전에는 해킹토시에 대한 글도 많이 검색하고 관심을 가졌는데...ㅎㅎ

댓글 남기기

* 이메일 정보는 공개되지 않습니다.