Vim에서 부드럽게 스크롤하는 가장 좋은 방법은 무엇입니까?
Vim의 주요 스크롤 명령은 다음과 같습니다.
- Ctrl- B및 Ctrl- F뿐만 아니라 PageUp및 PageDown스크롤로 전체 페이지
- Ctrl- U및 Ctrl- D기본적으로 절반 페이지 스크롤
- Ctrl- Y및 Ctrl- E한 줄 스크롤
앞의 두 사람은 매번 시각적 맥락을 잃어 버려 후자 ( Ctrl- Y와 Ctrl- E)를 반복적 으로 치는 나쁜 습관을 키 웠습니다 .
현재 부드러운 스크롤을위한 자사 지원이 없기 때문에 가장 불쾌한 해결 방법 / 플러그인은 무엇입니까?
나는 작업에 따라 Vim과 GVim을 모두 사용하며, 둘 다 작동하는 정말 좋은 해킹이 없다면 따로 커스터마이징 할 수있어 기쁩니다. 마우스 스크롤 휠은 GVim에서 잘 작동하지만 키보드 기반 솔루션을 찾고 있습니다.
업데이트 : 이제이 코드를의 지침에 따라 리팩토링 :help write-plugin하여 Github 저장소 에 푸시했습니다 .
키보드 사용
내 안에있는 것은 다음과 같습니다 .vimrc.
function SmoothScroll(up)
if a:up
let scrollaction="^Y"
else
let scrollaction="^E"
endif
exec "normal " . scrollaction
redraw
let counter=1
while counter<&scroll
let counter+=1
sleep 10m
redraw
exec "normal " . scrollaction
endwhile
endfunction
nnoremap <C-U> :call SmoothScroll(1)<Enter>
nnoremap <C-D> :call SmoothScroll(0)<Enter>
inoremap <C-U> <Esc>:call SmoothScroll(1)<Enter>i
inoremap <C-D> <Esc>:call SmoothScroll(0)<Enter>i
풍모:
- Vim
scroll옵션 의 바닥을 스크롤하십시오 . - 사용자 정의 가능한 스크롤 속도 (
sleep명령 의 시간 인수 조정 , 10 밀리 초 사용). 참고 : 비디오의 프레임 속도를 늦추는 것과 마찬가지로 부드러운 스크롤을 너무 많이 느리게하면 부드러운 스크롤이 아닌 저키 스크롤이됩니다. 그러나 당신에게 가장 적합한 것은 무엇이든. - 일반 또는 삽입 모드에서 작동합니다.
참고 : 복사하여 붙여 넣는 모든 사용자는 해당 ^문자가 제어 문자를 나타냄을 기억하십시오 . 복사-붙여 넣기는 잘못된 결과를 생성하므로 수동으로 입력해야합니다!
^Y- CTRL- V다음 CTRL-Y^E- CTRL- V다음 CTRL-E
그러나 <C-U>및 <Enter>스타일 구문은 문자 그대로 해당 문자로 입력됩니다. map 명령은 지능적으로 그것들을 제어 문자로 변환합니다.
마우스 사용
질문은 마우스 스크롤이 GVim에서 잘 작동하지만 키보드 솔루션이 필요하다는 것을 언급합니다. 이것은 질문자가 일반 터미널 Vim에서 작동하는 경우 마우스 솔루션에 관심이 있음을 의미합니다.
나를 위해 마우스 지원을 켜면 마우스 휠을 부드럽게 스크롤 할 수 있습니다. 또한 나를 위해 부드러운 스크롤은 내가 편집 할 때 (삽입 모드에서)가 아니라 주변을 둘러 볼 때 (즉, 일반 모드에서) 가장 중요하며, 내가 적극적으로 편집하지 않는 경우에는 키보드는 항상 제거되어 있으므로 잘 작동합니다.
그러나이 질문을 바탕으로 어떤 사람들은 단순히 마우스를 켜는 것 이상의 수동 설정을 수행해야하는 것 같습니다 set mouse=n.
내 .vimrc다음 줄이 있습니다.
set mouse=a
map <ScrollWheelUp> <C-Y>
map <ScrollWheelDown> <C-E>
vim의 tips.txt에는 간단한 리맵 해킹이 있습니다.
Smooth scrolling *scroll-smooth*
If you like the scrolling to go a bit smoother, you can use these mappings:
:map <C-U> <C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y>
:map <C-D> <C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E>
최근 플러그인
I have posted something similar here, but basically there is a great plugin that we can use now for scrolling, called terryma/vim-smooth-scroll. It provides a very nice and smooth scrolling.
The install is quite easy:
1 I use Vundle so I simply appended this in .vimrc.bundles :
Bundle terryma/vim-smooth-scroll
In the latest version of Vundle available today, 29th April of 2016, you can put this in your .vimrc:
Plugin 'terryma/vim-smooth-scroll'
2 As stated in the doc, you can set up 3 arguments: distance, duration and speed.
I am using this in my .vimrc file:
noremap <silent> <c-b> :call smooth_scroll#up(&scroll*2, 10, 4)<CR>
noremap <silent> <c-f> :call smooth_scroll#down(&scroll*2, 10, 4)<CR>
Shameless plug, but I created a plugin here that you can use to easily adjust the distance, speed, and duration of the scrolling animation: https://github.com/terryma/vim-smooth-scroll
This isn't exactly smooth scrolling, but it's how I handle not losing context when jumping pages.
set so=7
'scrolloff' 'so' number (default 0) global
{not in Vi}
Minimal number of screen lines to keep above and below the cursor. This will make some context visible around where you are working. If you set it to a very large value (999) the cursor line will always be in the middle of the window (except at the start or end of the file or when long lines wrap). For scrolling horizontally see 'sidescrolloff'. NOTE: This option is set to 0 when 'compatible' is set.
What I do is I set the keyboard repeat to very fast, about 120 chars / second, and the delay small. Then I map to 4j and to 4k I navigate up and down source code using j and k which moves the cursor up and down nice and quick, pretty smooth. But here's the good part, and this works on Linux, not Windows. For a number of years now, X11's keyboard input works in such a way that when you press and hold j it obviously starts putting out j characters. But when you then keep holding down j and then also press the ctrl key, X11 starts putting out c-j characters without you having to re-press the j key. Then when you let go of the ctrl key and still keep on pressing j, X11 continues to put j's again. So j makes the cursor start moving nice and smooth downwards, and you can periodically hit ctrl without letting go of j to give it a boost, a jolt.
Also, I do what Devin does, and I set scrolloffset to 5.
Lastly, I swap ctrl and cap lock. The default position of the ctrl key is completely retarded (no offense intended). It makes you have to rotate your left hand. I almost never use caps lock, so I swap them. Then my left pink finger can reach the ctrl key without any yoga moves.
These things have worked for me for years. I only use vim, never gvim.
The Plugin cskeeters/vim-smooth-scroll supports smooth scrolling and requires no configuration. It supports to support smooth scrolling with zt, zz, and zb. It's a fork of terryma's plugin. Some of the open pull requests have been applied.
I just found this plugin called "accelerated-smooth-scroll" ("Vim plugin for accelerated smooth scroll (mapping to <C-D>/<C-U>, <C-F>/<C-B>)") which can be for example used through Vundle by putting this line in your .vimrc:
Plugin 'yonchu/accelerated-smooth-scroll'
Then by restarting Vim and running the :PluginInstall command, then again restart Vim and use the <C-D> (Ctrl+D) and <C-O> (Ctrl+O) commands normally.
Sadly, this plugin also moves the cursor instead of what I wanted: to just scroll the screen like the <C-E> and <C-Y> commands.
참고URL : https://stackoverflow.com/questions/4064651/what-is-the-best-way-to-do-smooth-scrolling-in-vim
'IT TIP' 카테고리의 다른 글
| data.table로 할 수없는 data.frame으로 무엇을 할 수 있습니까? (0) | 2020.11.05 |
|---|---|
| 문서 기반 데이터베이스와 관계형 데이터베이스의 장단점 (0) | 2020.11.05 |
| WebSocket 요청-응답 서브 프로토콜 (0) | 2020.11.05 |
| Hibernate 주석을 사용하여 외래 키 제약을 어떻게 표시 할 수 있습니까? (0) | 2020.11.05 |
| JSON 웹 서비스는 CSRF 공격에 취약합니까? (0) | 2020.11.05 |