2018-09-02

ssh経由のtmuxの中で動くvimのウインドウサイズ変更にマウスを使う方法

私はマウスが好きだ。

30行以上、100列以上の文字が表示できる端末を使っている私にとっては、マウスは必須である。画面上に表示される任意の1文字にカーソルを合わせたい場合、キーボードだけでカーソルを移動させるのはとてもつらい作業である。一方、マウスならばその場にカーソルを動かすだけでよい。

端末を分割して複数の画面にする時、それぞれの画面のサイズをその場で微調整するには、キーボードで画面サイズの数値を指定するよりは、やはりマウスで直感的にドラッグしたい。

例えばvimだ。以下のようにすると

:set mouse=a

Vimはマウスを扱えるようになる。端末の任意の文字にカーソルを合わせるのにマウスを使えるのみならず、マウスでスクロールやマウスで範囲選択もできる。

Vimは画面を複数のWindowに分割できる。

:split
:vsplit

このとき、マウスを有効にしているとウインドウの枠をドラッグすることでサイズを直感的に変更できる。

tmuxも重要なソフトウェアだ。

tmuxは.tmux.confに以下の設定をすれば、

set -g mouse on

マウスを使えるようになる。マウスでスクロール、範囲選択ができるし、

Ctrl-b "
Ctrl %

で作ったtmuxのpaneのサイズもドラッグで直感的に変更できるようになる。

ところが、tmuxのなかで実行したvimのウインドウのサイズをマウスで変更できないことに気がついた。

調べた結果、これは.vimrcに以下のように書き込めばできる。

set mouse=a
set ttymouse=xterm2

どうやらxterm2にあるドラッグ中もマウス入力を通知し続ける機能を使うそうだ。tmuxも対応している。

これで問題は完璧に解決したと思ったが、もう一つ問題に出くわした。ssh先のリモートで実行したtmuxの中で実行したvimではマウスによるウインドウのりサイズができない。

これは.tmux.confに以下のように書けばできる。

set -g mouse on
setw -g alternate-screen on

man tmuxをみるとデフォルトでonになっているはずだが、なぜかUbuntu server 18.04ではonになっていないようだ。

これで以前からやりたかったssh越しにも違和感のまったくない環境を作ることができた。

21 comments:

いわもと こういち said...

ttymouse=xterm2には224桁問題があるので、ttymouse=sgrの方がお勧め。
SGR mouse modeに対応していない端末でもttymouse=xterm2相当で動くので、殆どの場合で問題が出ないはず。

사설토토 said...

hi

사설토토 said...

Very significant Information for us, I have think the representation of this Information is actually superb one 사설토토

사설토토 said...

I was always in search of such useful information you have shared in this blog. This will help me in my working 사설토토


사설토토 said...

온라인카지노 If you are going for finest contents like me, just go
to see this website daily for the reason that it presents quality contents, thanks

사설토토 said...

This is a topic which is near to my heart... Cheers!
Exactly where are your contact details though? 카지노사이트

opbest said...


Thanks for ones marvelous posting! I genuinely enjoyed reading it,
you’re a great author.I will be sure to bookmark your blog
and may come back down the road. I want to encourage you continue your great work,
have a nice afternoon!

My web site; 부산오피

(freaky)

magosucomwep said...

This article gives the light in which we can observe the reality. This is very nice one and gives in-depth information. Thanks for this nice article
국내경마

magosucowep

우리카지노 said...

There must have been many difficulties in providing this information.우리카지노 Nevertheless, thank you for providing such high-quality information.

메가슬롯 said...

When I read an article on this topic, 메가슬롯 the first thought was profound and difficult, and I wondered if others could understand.. My site has a discussion board for articles and photos similar to this topic. Could you please visit me when you have time to discuss this topic?

yadongbiz said...

If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings. Thank you for caring about your content. 야한동영상

Please visit once. I leave my blog address below
야설
야한동영상

yahanvideonet said...

I want to say thanks for beautiful blog sharing with us. Your blog really great resource to update my knowledge 일본야동

Please visit once. I leave my blog address below
한국야동
일본야동

koreayadongcom said...

What’s up to all, it’s genuinely a fastidious for me to visit this website, it consists of priceless Information. 한국야동닷컴

Please visit once. I leave my blog address below
국산야동
한국야동닷컴

japanyadongcom said...

you have done a great job. I will definitely dig it and personally recommend to my friends. I am confident they will be benefited from this site 국산야동

Please visit once. I leave my blog address below
야설
국산야동

chinayadongnet said...

Wow! After all I got a web site from where I can actually get valuable information regarding my study and knowledge. 중국야동넷

Please visit once. I leave my blog address below
야설
중국야동넷

baccaratsite.biz said...

Great Information sharing .. I am very happy to read this article .. thanks for giving us go through info.Fantastic nice. I appreciate this post.
바카라사이트비즈

roulettesitetop said...

I want to to thank you for ones time for this particularly wonderful read!! I definitely savored every part of it and i also have you saved as a favorite to see new information on your blog. 룰렛사이트탑

badugisitenet said...

This paragraph will assist the internet people for creating new website or even a weblog from start to end. 바둑이사이트넷

Anonymous said...

my loved one! I wish to say that this article is awesome, nice written and come with almost all significant infos. I¡¦d like to look extra posts like this . lets start work on this write-up, I seriously think this excellent website needs far more consideration. I’ll likely to end up again to learn a lot more, many thanks for that information. Valuable information. Fortunate me I discovered your website by accident, and I am stunned why this coincidence didn’t came about earlier! I bookmarked it. You’re the best, I was doing a google search and your site came up for real estate in Longwood, FL but anyway, I have enjoyed reading it, keep it up! 안전토토사이트

슬롯커뮤니티 said...

슬롯커뮤니티

Unknown said...

the Internet for information and came across your blog. I am impressed by the information you have on this blog. It shows how well you understand this subject.
카지노사이트
바카라사이트
우리카지노
온라인카지노
온라인바카라
라이브카지노