Disable cmd+k when using Vim in terminal?
Asked Answered
G

2

11

So when I'm using Vim in the mac osx terminal I accidentally enter the command cmd+k that clears my terminal because I'm used to the motion, this makes me have to exit vim and enter again. I want to know if theres a way to disable this.

For example this is me editing my .vimrc

enter image description here

Then I enter the command and my terminal looks like this:

enter image description here

Is there a way to disable this command when using Vim only? I want to continue using it when using the terminal outside Vim. Thanks

Gradus answered 24/2, 2018 at 22:47 Comment(3)
Instead of restarting vim try CTRL-L to redraw the screen.Heartfelt
@Heartfelt That seems to work fine, please submit your comment as an answer so that I can check it. Thanks.Gradus
Thanks for asking this. I do this regularly, and it's oddly absent from discussion whenever I've searched for the command (where is it in the docs?). Usually you need to mentally translate cmd to ctrl when using vim on a Mac, but here ctrl+k doesn't perform the task, but ctrl+l undoes it. I've tried displaying all key mappings or getting help for CMD-K from within vim, but get no results. Anybody have a doc link for this?Spaghetti
H
8

Instead of restarting vim use CTRL-L to redraw the screen.

Heartfelt answered 25/2, 2018 at 0:26 Comment(2)
It helps, but it doesn't really fix the problem. I still need to manually ctrl-l when I accidentally cmd-k. Is it possible to disable cmd-k completely? I use option-k as the vim "up" key, and I accidentally click cmd instead of option because of the poor keyboard ergonomics.Radloff
Also doesn't seem to work if I am in vim in a tmux sessionRadloff
M
0

Found the answer to this question while looking for how to do the same thing in tmux

https://superuser.com/questions/611373/with-tmux-on-osx-how-can-i-make-commandk-clear-more-gracefully

Essentially, tell iTerm2 to map cmd+k to send the control sequence 0x0c

Mummify answered 21/5 at 5:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.