화면의 카피 모드에 대해 vim과 같은 CW F를 가질 수 없습니다.
-
23-08-2019 - |
문제
화면의 카피 모드에서 VIM으로가는 경로를 열고 싶습니다.
Ctrl-A f
마찬가지로 Vim에서 외부 파일을 열 수있는 것과 마찬가지로
Ctrl-W f
화면의 사본 모드에서 VIM에서 경로를 어떻게 열 수 있습니까?
--- Samuil이 Crux 움직임을 가져 주셔서 감사합니다.
마우스가 화면이 켜져있을 때 디스플레이를 나타내는 다음 코드의 경로/파일에 있다고 가정 해 봅시다.
text[space]PATH/file[space]text
경로/파일에서 ^a f를 누릅니다. 파일의 경로를 우리가 사용할 수 있도록 /tmp /screencopyfile에 저장해야합니다. cat
다음 명령에서 ^A f
시작해야합니다 :
^A: exec vim `cat PATH/file`
명령을 수동으로 실패합니다. CAT 명령을 확장하지는 않았지만 CAT라는 파일을 엽니 다.
다시 말해, 우리는 편지를 만들고 싶습니다 f
의지합니다
exec vim `cat /tmp/screenCopyFile`
.screenrc에서 결합하여.
답변 해 주셔서 감사합니다!
해결책
알겠습니다. 여기에 해결책이 있습니다.
다음을 넣으십시오 /path/to/edit-file-under-cursor.screen
:
# edit-file-under-cursor.screen
# prevent messages from slowing this down
msgminwait 0
# copy path starting at cursor
stuff " Ebe "
# write the path to a file
writebuf /tmp/screen-copied-path
# open that file in vim in a new screen window
screen /bin/sh -c 'vim `cat /tmp/screen-copied-path`'
# turn message waiting back on
msgminwait 1
# vi: ft=screen
그런 다음이 줄을 추가하십시오 .screenrc
:
# bind CTRL-f to open the file starting at the cursor
# when in copy mode
bindkey -m ^f source /path/to/edit-file-under-cursor.screen
(변경 /path/to/
적절하게)
그런 다음 사용하려면 다시 시작하십시오 screen
(또는 다시로드 .screenrc
). 복사 모드를 입력하십시오 ^A[
, 파일 이름의 첫 번째 캐릭터에 대한 커서, 그 다음 CTRL-f
.
나는 이것을 테스트했는데 그것은 나에게 효과가 있으므로 문제가 있는지 말해줘.
내가이 작업을 수행하는 방법을 알고 싶다면 확인하십시오. man screen
모든 다양한 명령이 어떻게 작동하는지 확인합니다.
한 가지 개선은 경로의 시작을 찾을 수 있다는 것이지만 화면의 사본 모드 이동 명령만으로 안정적으로 할 수 없었습니다 (예 : 첫 번째로 이동 한 모든 것 /
의 "/a/path
" |
의 "|/a/path
")
이것은의 한계 때문입니다 screen
복사 모드의 이동 명령 :
Movement keys: h, j, k, l move the cursor line by line or column by column. 0, ^ and $ move to the leftmost column, to the first or last non-whitespace character on the line. H, M and L move the cursor to the leftmost column of the top, center or bottom line of the window. + and - positions one line up and down. G moves to the specified absolute line (default: end of buffer). | moves to the specified absolute column. w, b, e move the cursor word by word. B, E move the cursor WORD by WORD (as in vi). C-u and C-d scroll the display up/down by the specified amount of lines while preserving the cursor position. (Default: half screen-full). C-b and C-f scroll the display up/down a full screen. g moves to the beginning of the buffer. % jumps to the specified percentage of the buffer. ... Searching: / Vi-like search forward. ? Vi-like search backward. C-a s Emacs style incremental search forward. C-r Emacs style reverse i-search.
그래서 우리가 변경했다면 stuff
위의 라인
stuff "Bw Ebe "
그것은 경로의 시작으로 이동할 것이지만, 길 앞에 온 비 냉담한 쓰레기도 포함됩니다. 따라서 모든 경로가 공백으로 구분되는 한 (양쪽에) 이것은 작동해야합니다.
실제로
stuff "B//^M E?/^Me "
첫 번째와 마지막을 찾기 위해 검색을 사용하기 때문에 상당히 잘 작동하는 것 같습니다. /
(입력하십시오 ^M
Ctrl-V를 치고 VIM에서 입력하십시오). 나는 모든 Edge 케이스를 테스트하지는 않았지만 다음과 같은 것 같습니다.
/a/path #/a/path /a/path#
그러나 실패 할 것입니다
a/relative/path
다른 팁
나는 VIM을 너무 잘 알지 못하지만 몇 가지 명령으로 쉽게 수행해야합니다. 페이스트 버퍼에 이미 파일 이름이있는 경우 다음 유용한 명령을 사용할 수 있습니다.
^A : writebuf /tmp/.screenpomfile
^A : exec vim parameters
나는 어떻게 만드는 방법을 모른다 vim
파일에서 파일 이름을 읽었습니다 (가능하다고 생각합니다). :exec
구문 분석 할 수있는 쉘로 작성된 자신의 대본 `expr
`표현 :
#!/bin/sh
vim `cat /tmp/.screenpomfile`
나중에 자신의 열쇠를 이러한 행동에 묶어 매우 효과적으로 사용할 수 있습니다.