Posts tagged with “vim”

Don't change the inode when editing a file with Vim

I keep my config files on github, and I use hard-link for most of the config files. It's convenient, as I can check the new changes easily and submit some of the changes when necessary. However, the default behavior of vim troubles me. It always changed the inode when I save the config file!

tldr; the solution is: put the following line in your .vimrc

set backupcopy=yes

PS Though this way fixed Vim's behavior, I sadly found that git pull will change the config file's inode as well. So there is actually no feasible solution. I have abandoned this hard link approach. If you have better solutions to maintain all your config files in one repository, please let me know!

Rider Terminal tips

  1. Stop Leaving the Terminal when you press the Escape key. It is really annoying when you are a vim fan like me! here's the solution

    Go to "Settings | Tools | Terminal" and click "Configure terminal keybindings".
    Find "Plug-ins | Terminal | Switch Focus To Editor" action and change its keyboard shortcut (by default "Escape") via the context menu.
    Keybindings are IDE-wide, so there is no need to change them for each project.

  2. Using msys2 bash as the embedded terminal: at Settings > Tools > Terminal
    Environment Variables: CHERE_INVOKING=1
    Shell path: c:\msys64\usr\bin\bash.exe --login

    Unfortunately, the environment variables above work only on the current project; It is definitely a tedious process that you have to repeatedly set it up for every project. So I eventually found a better way to achieve the same goal without setting up the Environment variables in Rider. Here is the answer Reference:

    Shell path:  C:\msys64\msys2_shell.cmd -defterm -here -no-start


vim 命令模式粘贴寄存器中复制好的内容:先Ctrl+R,再输入寄存器名字。默认寄存器名字是 "

vim 命令模式粘贴寄存器中复制好的内容:先Ctrl+R,再输入寄存器名字。默认寄存器名字是 "

vim 向上删除 n 行

我们都知道从当前行往下删除 n 行很容易, ndd 就好了。但往上删除呢? 我以前是不知道的,最近搜索了一下,找到了答案,而且额外学到了其他的技巧,你想听吗(不想听我也会写,哈哈

8dd其实是dd重复8次,容易记忆,但效率很低。正确的姿势是 7dj 或者 d7j。我想你看到这里已经猜到应该怎么向上删除了。如果打算从当前行往上删除n行,你需要 {n-1}dk 或者 d{n-1}k

故事到这里应该结束了,然而.... 试试 V3kd, V4jd,注意是大写的V。你会对vim的强大有更多的理解。

By the way, 如果你要从当前行删除到你知道行号的某一行,举例来说,你要从当前行一直删到第434行,无所谓是向上删还是向下删,用 d434G 就可以了。