Vim의 명령 줄 모드에서 일반 모드 모션 사용
명령 줄 모드에서 모달 편집이 가능합니까?
몇 가지 예 :
- 글을 쓴 후 바를 삭제
!ls ~/foo/bar
하고 싶습니다db
- 나는 위의 명령을 실행하고 지금은 변경할
ls
에mv
와 $로 다시 이동
기본적으로 Vim 명령 줄에서를 누르 Control + f
거나를 볼 set cedit
수 있습니다. 그러면 일반 모드 Vim 편집 키를 사용하여 명령을 편집 할 수있는 명령 줄 창이 열립니다. Enter
명령을 실행하거나 Control + c
표준 명령 줄로 돌아갑니다.
따라서 특정 예제 Control + f
에서 Vim 명령 줄을 db
누르면 원하는 작업을 수행 할 수 있습니다.
더 정교한 편집 명령을 수행해야 할 때 위의 접근 방식을 사용합니다. 다른 대안보다 Vim 편집 키에 더 익숙하기 때문입니다. 또한 일반 모드 vim 키가 더 강력하다는 것을 알았습니다.
자세한 내용은를 참조하십시오 :help c_ctrl-f
.
에서 정력 의 '커맨드 라인 모드 : <ctrl-w>
단어를 삭제
에서 일반 모드 : q:
(VIM 명령을 편집 할 수 있습니다) 명령 기록에 간다
:help cmdline-editing
및 :help cmdline-window
더 많은 명령을 참조하십시오 .
명령 줄 모드에서 이동 및 편집을위한 내장 핫키
<Esc> abandon command-line without executing it
CTRL-C abandon command-line without executing it
CTRL-B cursor to begin of command-line
CTRL-E cursor to end of command-line
CTRL-F opens the command-line window (unless a different key is specified in 'cedit')
CTRL-H delete the character in front of the cursor (same as <Backspace>)
CTRL-W delete the word in front of the cursor
CTRL-U delete all characters in front of the cursor
CTRL-P recall previous command-line from history (that matches pattern in front of the cursor)
CTRL-N recall next command-line from history (that matches pattern in front of the cursor)
<Up> recall previous command-line from history (that matches pattern in front of the cursor)
<Down> recall next command-line from history (that matches pattern in front of the cursor)
<S-Up> recall previous command-line from history
<S-Down> recall next command-line from history
<PageUp> recall previous command-line from history
<PageDown> recall next command-line from history
<S-Left> cursor one word left
<C-Left> cursor one word left
<S-Right> cursor one word right
<C-Right> cursor one word right
<LeftMouse> cursor at mouse click
(이전 답변과 중복되어 죄송합니다. 그럼에도 불구하고이 완전하고 구조화 된 개요가 유용하기를 바랍니다.)
° 2014 년 현재 – 그 이후로 새로운 키보드 단축키가 추가되었을 수 있습니다.
:help cmdline-editing
Vim에서 검색하십시오 .
It will give a list of shortcut working in command line mode.
An extract for your current problem :
CTRL-B or <Home> *c_CTRL-B* *c_<Home>*
cursor to beginning of command-line
CTRL-E or <End> *c_CTRL-E* *c_<End>*
cursor to end of command-line
<S-Left> or <C-Left> *c_<C-Left>*
cursor one WORD left
*c_<S-Right>*
<S-Right> or <C-Right> *c_<C-Right>*
cursor one WORD right
or use q:
as mentioned by Rene which allows you to edit previous typed commands in different modes.
Plugins for "Normal mode"-like Command-line editing
emacscommandline makes the command-line mode behave more like the Unix command line, by adding Emacs-style mappings (like in the Bash shell). Some of the mappings just map existing vim commands, but the rest implement functionality that is not available natively.
conomode.vim implements a kind of Normal mode ( "Cmdline-Normal mode" ) on top of the Command line. Purpose is similar to the cmdline-window (q:), but navigation and editing can be done in-place. Of course the cmdline-window is much more powerful.
Conomode does not replace Vim's native emacs-style command line editing, it just adds one key: CTRL-O (see below).
- enter with c_ (press CTRL-O while in Command-line mode)
- mode indicator is a colon ":", moved along with the cursor, hiding the char under it
- quit to Cmdline-mode with I, i, a, A, : or any unmapped key (which then executes or inserts itself), or wait 60 seconds.
- quit to Normal mode with Esc
(Admittedly, I don't understand the point of this plugin, since instead of hitting Ctrl+O to enter its Cono-mode, you could just as quickly pop up the command-line window with Ctrl+F.)
There might be other plugins out there. → https://www.google.com/webhp?q=command-line+editing+plugin+vim
Instead of employing a full-blown plugin, or as a complement to it, you can define your own mappings. → See my other answer.
Custom mappings that replicate Normal mode commands
You can manually map specific Normal commands to keystrokes in Command-line mode.
For example the following set of mappings will make Alt+h in Command-line mode go one character left, Alt+k recall the previous Ex command and so on, analogously to hjkl in Normal mode.
" provide hjkl movements in Command-line mode via the <Alt> modifier key
cnoremap <expr> <A-h> &cedit. 'h' .'<C-c>'
cnoremap <expr> <A-j> &cedit. 'j' .'<C-c>'
cnoremap <expr> <A-k> &cedit. 'k' .'<C-c>'
cnoremap <expr> <A-l> &cedit. 'l' .'<C-c>'
Since the Alt modifier key is not mapped (to something important) by default, you can in the same fashion pull other (or all) functionality from Normal mode to Insert mode. E.g.: Moving to the beginning of the current word with Alt+b:
" Normal mode command(s) go… --v <-- here
cnoremap <expr> <A-b> &cedit. 'b' .'<C-c>'
cnoremap <expr> <A-w> &cedit. 'w' .'<C-c>'
" <Alt>+<i> changes the first word (typically
" the last run Ex :command or the last range, given the case)
cnoremap <expr> <A-i> &cedit. '^cw' .'<C-c>'
You have to copy that code into your vimrc file to have it loaded every time you start vim (you can open that by typing :new $myvimrc
starting in Normal mode).
Instead of "reinventing the wheel", or as a complement to your own mappings, you can draw on full-featured plugins from other authors → see my other answer.
참고URL : https://stackoverflow.com/questions/7186880/using-normal-mode-motions-in-command-line-mode-in-vim
'UFO ET IT' 카테고리의 다른 글
Git 저장소 재 패키지 실패 (0) | 2020.12.14 |
---|---|
상대 시간에 대한 Javascript 타임 스탬프 (예 : 2 초 전, 1 주 전 등), 최상의 방법? (0) | 2020.12.14 |
C #에 "잠금 시도, 시간 초과시 건너 뛰기"작업이 있습니까? (0) | 2020.12.14 |
phpmyadmin이 포함 된 PHP 7은 많은 지원 중단 알림을 제공합니다. (0) | 2020.12.13 |
OSX의 MAMP에서 Apache가 시작되지 않지만 MySQL은 작동합니다. (0) | 2020.12.13 |