Use Mouse in Terminal Vim like a modern editor

现代的编辑器(Ultraeditor, Editplus) 对于鼠标的使用非常频繁,最常见的是使用鼠标单击来移动光标,鼠标滚轮来上下翻页,或者鼠标双击选中某个词,然后拷贝或者粘贴替换。我最近学到了如何在Terminal-Based Vim 中也这样操作。

首先设置Vim 在 Normal Mode 和 Visual Mode 下激活鼠标:

set mouse=nv

这样我们就可以用鼠标单击或者滚轮移动光标了。另外,鼠标双击选中单词也正常工作了。

值得一提的是,我们也可以用键盘来选中一个词:假定我们的光标停在 information 这个词上(任何位置都可以),按下

viw

就可以选中整个词,这个操作不需要鼠标,在某些情况下很方便。

接下来的事情就容易了,拷贝:

y

粘贴并替换当前选中的词:

p

 

编译 Vim (Compile Vim Wiht Python 3 Support on Debian)

下载源文件

$ git clone https://github.com/vim/vim.git
$ cd vim/src
$ vi Makefile

编辑Makefile

  • 选择编译器
# COMPILER - Name of the compiler {{{1
# The default from configure will mostly be fine, no need to change this, just
# an example. If a compiler is defined here, configure will use it rather than
# probing for one. It is dangerous to change this after configure was run.
# Make will use your choice then -- but beware: Many things may change with
# another compiler. It is wise to run 'make reconfig' to start all over
# again.
#CC = cc

# For some reason, gcc does not install itself as /usr/bin/gcc
CC = gcc-9
#CC = clang

if gcc is not installed, installing it by running

$ sudo apt update
$ sudo apt install build-essential
  • 关闭图形
# GUI - For creating Vim with GUI (gvim) (B)
# Uncomment this line when you don't want to get the GUI version, although you
# have GTK, Motif and/or Athena. Also use --without-x if you don't want X11
# at all.
CONF_OPT_GUI = --disable-gui

# X WINDOWS DISABLE - For creating a plain Vim without any X11 related fancies
# (otherwise Vim configure will try to include xterm titlebar access)
# Also disable the GUI above, otherwise it will be included anyway.
# When both GUI and X11 have been disabled this may save about 15% of the
# code and make Vim startup quicker.
CONF_OPT_X = --without-x
  • 支持  Python3

安装 Python3 库文件

$ sudo apt install python3.8 python3.8-dev python3-distutils

静态链接 Python 解释器。

# PYTHON
# Uncomment lines here when you want to include the Python interface.
# This requires at least "normal" features, "tiny" and "small" don't work.
# NOTE: This may cause threading to be enabled, which has side effects (such
# as using different libraries and debugging becomes more difficult).
# For Python3 support make a symbolic link in /usr/local/bin:
# ln -s python3 python3.1
# If both python2.x and python3.x are enabled then the linking will be via
# dlopen(), dlsym(), dlclose(), i.e. pythonX.Y.so must be available
# However, this may still cause problems, such as "import termios" failing.
# Build two separate versions of Vim in that case.
#CONF_OPT_PYTHON = --enable-pythoninterp
#CONF_OPT_PYTHON = --enable-pythoninterp --with-python-command=python2.7
#CONF_OPT_PYTHON = --enable-pythoninterp=dynamic
#CONF_OPT_PYTHON3 = --enable-python3interp
#CONF_OPT_PYTHON3 = --enable-python3interp --with-python3-command=python3.8
#CONF_OPT_PYTHON3 = --enable-python3interp=dynamic

CONF_OPT_PYTHON3 = --enable-python3interp --with-python3-command=python3.8 --with-python3-config-dir=/usr/lib/python3.8/config-3.8-x86_64-linux-gnu

编译和安装

$ make

$ sudo make install

清理一切,从头开始

$ make distclean

 

第一代之后,基因型不再变化(Stationary GenoType Distribution)

基因 A 和 a是一对等位基因,在人群中构成了三种基因型:AA, Aa 和 aa,其中A是显性,a是隐性。在某些遗传性状比如蓝眼睛、左撇子等,基因型决定了实际表现的性状,假定A代表右撇子,a代表左撇子,那么Aa和AA都表现为右撇子,只有aa表现为左撇子。

假定这三种基因型在男性和女性中的分布概率是一样的,分别是 u, 2v, w,那么我们有:

(1)   \begin{equation*} \begin{split} P(AA) = u \\ P(Aa) = 2v \\ P(aa) = w \\ u + 2v + w = 1 \end{split} \end{equation*}

如果我们用p代表基因A在人群中的概率,我们有:

(2)   \begin{equation*} P(A) = p = u + v \end{equation*}

同样,我们用q代表基因a在人群中的概率,我们同样有:

(3)   \begin{equation*} P(a) = q = w + v \end{equation*}

因为我们假定男性和女性的基因型分布是一样的,那么对于下一代子女来说,因为他(她)们的基因一半来自父亲,另一半来自母亲,所以他们之中纯合基因型AA发生的概率就是继承自父亲和母亲的基因都是A的概率相乘,也就是:

(4)   \begin{equation*} u_1 = p^2 = {(u+v)}^2 \end{equation*}

根据同样的道理,子女代中基因型Aa和aa发生的概率分别是:

(5)   \begin{equation*} \begin{split} 2v_1 = 2pq = 2 (u+v)(w+v) \\ w_1 = q^2 = {(w+v)}^2 \end{split} \end{equation*}

上面的公式中我们依然使用 u, v, w 代表 基因型AA,Aa和 aa 的概率,但是使用下标1来表示这是子女代。有了每种基因型的概率之后,我们可以知道子女代中实际基因A和a的分布概率是:

(6)   \begin{equation*} \begin{split} p_1 = u_1 + v_1 \\ q_1 = w_1 + v_1 \end{split} \end{equation*}

那么再下一代的三种基因型的概率分别是多少呢,同样我们可以简单计算如下:

(7)   \begin{equation*} u_2 = p_1^2 = {(u_1 + v_1)}^2 = u_1^2 + 2u_1v_1 + v_1^2 \end{equation*}

(8)   \begin{equation*} \begin{split} &2v_2 = 2 p_1 q_1 \\ &= 2(u_1 + v_1)(w_1 + v_1) \\ &= 2u_1w_1 + 2 u_1v_1 + 2v_1 w_1 + 2v_1^2 \end{split} \end{equation*}

(9)   \begin{equation*} w_2 = q_1^2 = {(w_1 + v_1)}^2 = w_1^2 + 2w_1v_1 + v_1^2 \end{equation*}

同样,第二代中基因A和a的概率分别是:

(10)   \begin{equation*} \begin{split} p_2 &= u_2 + v_2 \\ &= (u_1^2 + 2u_1v_1 + v_1^2) + \\ &\quad (u_1w_1 +  u_1v_1 + v_1 w_1 + v_1^2) \end{split} \end{equation*}

(11)   \begin{equation*} \begin{split} q_2 &= w_2 + v_2 \\ &= (w_1^2 + 2w_1v_1 + v_1^2) + \\ &\quad (u_1w_1 +  u_1v_1 + v_1 w_1 + v_1^2) \end{split} \end{equation*}

计算了这么拉拉杂杂一大堆,到底有什么用处呢?下面是关键的一步,因为我们有:

(12)   \begin{equation*} p + q = u + 2v + w = 1 \end{equation*}

显而易见:

(13)   \begin{equation*} q = 1 - p \end{equation*}

我们很容易推导出上一代的基因A的概率和下一代基因A的概率关系如下:

(14)   \begin{equation*} p_1 = u_1 + v_1 = p^2 + pq = p^2 + p(1-p) = p \end{equation*}

同样的道理,我们也可以看到:

(15)   \begin{equation*} \begin{split} q_1 = q \\ p_2 = p_1 \\ q_2 = q_1 \\ p_3 = p_2 \\ q_3 = q_2 \\ ... \end{split} \end{equation*}

上式说明,在理想的情况下(基因A和a在男女中比例一致,每一个人都有同样的机会生育下一代,下一代的生男孩女孩的概率一致),每一代中基因A和a的分布实际上没有任何变化,这也符合我们关于遗传的直觉。但是基因型AA,Aa和aa的概率就不是这样了。一般情况下:

(16)   \begin{equation*} \begin{split} u_1 \ne u \\ v_1 \ne v  \\ w_1 \ne w \end{split} \end{equation*}

但是

(17)   \begin{equation*} \begin{split} u_1 = u_2 \\ v_1 = v_2  \\ w_1 = w_2 \\ u_2 = u_3 \\ v_2= v_3  \\ w_2 = w_3 \\ ... \end{split} \end{equation*}

这说明实际的基因型在第一代之后就稳定下来,不再变化。回到我们前面左撇子的例子:在理想情况下,第一代和第二代的左撇子比例(基因型,u,v,w)可能不一样,但是他们中的左撇子基因(p,q)实际是一致的,从第二代以后,基因型的比例也稳定下来,不再变化。

戒掉围棋,立此为证(Swear Off Go Game)

下棋劳神费力,导致头疼,这个年纪已经不再合适。

下棋远离家人,却贴近陌生人,本末倒置。

下棋浪费时间,大好光阴本可用于学习与工作。

下棋所争无非输赢,虚荣好胜,引以为耻。

从此把棋盘、棋子、棋书束之高阁;新闻、视频、论坛关禁了事。

立此为证,敬请家人朋友监督。

Playing Go consumes a lot of brain power, causes headache, which is inappropriate for my age.

I spend a lot of time on playing Go with strangers, which could instead be spent with family.  This behavior puts the incidental before the fundamental.

A lot of time is spent on Go playing, which could be used on learning  and studying other interesting things.

The whole point of playing Go on Web is for winning vanity, this should be a shame for any noble men.

Putting the stones, boards and books on attic space, blocking the news, videos and forums on computers.

Family, please help me to keep this promise.

对抗假新闻

现在互联网上的假新闻越来越多,有一些是无心的以讹传讹,但是也有很多是别有用心的杜撰,专门用来混淆视听的。传统的大媒体比如BBC、卫报还好一些,论坛、自媒体以及社交网络都是重灾区。关于新型冠状病毒的假新闻,过去的这六个月来就遇到了很多,比如有假新闻说英国首相鲍里斯在感染新冠之后,虽然勉强活命,但是身体严重受损,无法坚持工作,不得不辞去首相职位。最新的一则是前一天有报道说俄罗斯的疫苗研制成功,普京总统亲自下令全民接种,自己的大女儿以身作则,率先尝试。这消息已经相当使人震惊,毕竟疫苗是人命关天的大事,俄罗斯在疫苗研制方面的火箭速度实在是不同寻常。可是隔天就又有新的消息,说俄罗斯疫苗研制失败,普京的大女儿已经因为接种疫苗的不良反应挂了!!!  这消息也太过耸人听闻了吧,实在让人难以相信。联想起前一阵子一个中文自媒体播报说末任香港总督彭定康已经向海牙国际法庭提交诉讼,要把香港的主权重新交还给英国,我当时也是大吃一惊,最后也悄无声息,又是一个假新闻。

互联网上的假新闻实在是太多了,干脆眼不见心不烦,专注于自己的家人、学习、工作吧。

音乐欣赏的两个对比

以前自己都是只会打开音响听音乐,自从自己开始弹琴以后,才慢慢悟出来音乐欣赏这里面还有两个有趣的对比:第一,同样一首歌曲,听别人弹和听自己亲手弹出来的感觉,后者带来的愉悦要大得多,听着旋律与和声跟随着自己手指的动作流淌出来,即使是很简单的曲目,也很享受,要是别人弹,可能就会觉得这旋律很简单,没什么特别的。第二,钢琴想要弹到别人觉得好听要比自己觉得好听难得多,常常一段旋律自己弹得摇头晃脑,乐在其中,可是家人已经听过无数遍了,早已听得滚瓜烂熟,耳朵起茧了。

看来要想领会音乐的妙处,自己动手实践是一个好办法呀。

打开 Do Not Disturb

过去半年多以来,手机上收到的诈骗电话多到了无以复加的地步。让我只能感慨世风日下,人心不古。无奈之下,我只有抓起电话研究一下如何过滤这些电话。最后的结论是Android 有一个选项是 “Do Not Disturb”,打开以后就只有你的通讯录上的人给你打电话才能响铃,其他的电话就全部过滤掉了。看来这是目前最为有效的方法了。

The Art of Piano Fingering: Traditional, Advanced, and Innovative is very useful book

During the Covid 19, I have to give up my ping pong play since it is impossible to find partners any more.  It did not take me long to decide to pick up piano as the next activity, since I have a piano right at home. After some basic scales practice and childish songs, I decided to start to try some more adult-style songs since it is really hard to keep motivated if I keep playing those naive songs. Anyway, first I picked a well-known song The Moon Represents My Heart, and it took me a few weeks to be able to play it by heart without making any mistakes (but not always be able to do so), then I picked a new song The main theme from XuanYuan Sword:The Scar of the Sky, although this one looks only a little bit harder than the previous one, but it proves beyond me: I practiced for a few weeks, but only finished the  one third, and never be able to play even this one third part without any mistakes: some part are just too hard to play, let along the fact many part are played in a quite hasty way, and music produced by me also sounds poor.

Only at this occasion, it occurred to me that I need some help instead of just keep trying by myself, not just some music theory, but some more practical guide about playing piano. Very fortunately, I found the book The Art of Piano Fingering: Traditional, Advanced, and Innovative, which focuses on fingers arrangement in piano play. It has a lot of simple but very effective advice for how to arrange fingers for various music pieces, from simple scales, triads, to arpeggios which spans more than 1 octave. By applying these advice to my piano, I can play the  The Moon Represents My Heart with more confidence and easier hand moves, and got some new ideas about how to play The main theme from XuanYuan Sword:The Scar of the Sky. Hopefully in the next a few weeks, I can really master this song and I am looking forward to that day. 🙂

Text from Yeti:

BTW I am thinking about getting a digital piano cuz I seem to be driving Yeti crazy soooooo yea abut dat anyways i should rlly start to apply the pedal more cus life would just be so much easier ok thats it yeti out baiiiii :))) :PP

国际政治是受伤害最深的学科

今天在网上闲逛,偶尔看见《小县城的中年粉红:在混吃等死中研究世界局势》一文,下面一段文字倒是激起了我很多共鸣:

在两个多小时的边吃边聊中,我不时感叹,信息技术革命,手机上网普及,最受伤害的学科是国际政治。国际政治的文章大多数是叙述性的,不需要抽象和精深的理论,初中毕业就读得懂。国际政治的信息碎片在网上遍地都是,拿起扫帚随便扫一扫,就能扫一箩筐。以至于国际政治如今已成门槛最低的公共话题。但是,聊世界局势,逼格却很高。

作者的观察很准确呀,现在YouTube上纵论国际政治的中文自媒体越来越多,不就是一个活生生的证据吗。无论是“文昭谈古论今”、“王剑每日观察”,还是“stone 记”,话题都是围绕着国际政治展开。按照文章作者的说法,这些才是真正的聪明人:

复旦名嘴张维为、人大教授金灿荣、局座张召忠、” 至道学宫 ” 创办人 …… 才是这个时代最具 ” 顶级智慧 ” 的人。面对如此庞大的粉红群体,你既然改变不了他们,何不利用他们赚钱呢?

自己还是应该把自己力所能及的事情做好,有所学习,有所长进。国际政治这么高水平的学科,就留给有兴趣又有能力的人们吧。

轮指不如移手 (Moving Hands is much better than using thumb and index fingers alternatively)

《天之痕》里面有一部分的左手和弦是连着两个小节的上行四分音符,这两个小节下来以后,左手就向高音部分移动很远,接着弹下面小节的和弦又要向低音部分移动回来很多,自己常常弹得手忙脚乱,错误连连。苦练了很久,进展不大。直到今天下午,自己才突然认识到:原来自己处理上行音阶,全部是用拇指和食指交替进行,虽然一时方便,但是整个左手手掌的姿态是很不协调的,这样给快速切换到下一个小节的低音带来了很大的困难;如果我采用移动手掌的办法来处理上行音阶,虽然弹起来稍微难一点,但是整个左手的姿态是舒展的,大拇指按完最后一个高音四分音符,左手很容易快速向左移动用小拇指去够下一个小节的低音。其实这件事情我女儿 Yetao 很早就向我指出过,只是当时没有明白这个道理。想通了这个道理以后,我按照新的方法练习了一会,结果原来老也弹不好的几个小节,竟然奇迹般的变得轻松起来。听着音乐从自己的手指下流淌出来,这种感觉真是让人陶醉。特别是当整个乐曲中从来没有顺利弹出的那一小段在自己的双手中完美呈现出来的那一刻,我感到极大的感动:所有的辛劳都得到了最大的回报,真是太美好了。