Vim
Why Vim
In my opinion, the Vim editor has the following benefits:
- It keeps your finger on the keyboard throughout the development and moving the cursor without the arrow keys keeps your fingers in the best position for typing.
- Convenient file switching and panel controls allow you to edit multiple files simultaneously or even different locations of the same file.
- Vim's macros can batch repeat operations (e.g. add tabs to multi-lines, etc.)
- Vim is well-suited for Linux servers without GUI. When you connect to a remote server through
ssh, you can only develop from the command line because there is no GUI (of course, many IDEs such as VS Code now providesshplugins to solve this problem). - A rich ecology of plugins gives you the world's most fancy command-line editor.
How to learn Vim
Unfortunately Vim does have a pretty steep learning curve and it took me a few weeks to get used to developing with Vim. You'll feel very uncomfortable at first, but once you get past the initial stages, trust me, you'll fall in love with Vim.
There is a vast amount of learning material available on Vim, but the best way to master it is to use it in your daily development, no need to learn all the fancy advanced Vim tricks right away. The recommended learning path is as follows:
- Read This tutorial first to understand the basic Vim concepts and usage.
- Use Vim's own
vimtutorto practice. After installing Vim, typevimtutordirectly into the command line to enter the practice program. - Then you can force yourself to use Vim for development, and you can install Vim plugins in your favorite IDE.
- Once you're fully comfortable with Vim, a new world opens up to you, and you can configure your own Vim on demand (by modifying the
.vimrcfile), and there are countless resources on the Internet to learn from.
Recommended References
- Neil, Drew. Practical Vim: Edit Text at the Speed of Thought. N.p., Pragmatic Bookshelf, 2015.
- Neil, Drew. Modern Vim: Craft Your Development Environment with Vim 8 and Neovim. United States, Pragmatic Bookshelf.
Vim
Why Vim
In my opinion, the Vim editor has the following benefits:
- It keeps your finger on the keyboard throughout the development and moving the cursor without the arrow keys keeps your fingers in the best position for typing.
- Convenient file switching and panel controls allow you to edit multiple files simultaneously or even different locations of the same file.
- Vim's macros can batch repeat operations (e.g. add tabs to multi-lines, etc.)
- Vim is well-suited for Linux servers without GUI. When you connect to a remote server through
ssh, you can only develop from the command line because there is no GUI (of course, many IDEs such as VS Code now providesshplugins to solve this problem). - A rich ecology of plugins gives you the world's most fancy command-line editor.
How to learn Vim
Unfortunately Vim does have a pretty steep learning curve and it took me a few weeks to get used to developing with Vim. You'll feel very uncomfortable at first, but once you get past the initial stages, trust me, you'll fall in love with Vim.
There is a vast amount of learning material available on Vim, but the best way to master it is to use it in your daily development, no need to learn all the fancy advanced Vim tricks right away. The recommended learning path is as follows:
- Read This tutorial first to understand the basic Vim concepts and usage.
- Use Vim's own
vimtutorto practice. After installing Vim, typevimtutordirectly into the command line to enter the practice program. - Then you can force yourself to use Vim for development, and you can install Vim plugins in your favorite IDE.
- Once you're fully comfortable with Vim, a new world opens up to you, and you can configure your own Vim on demand (by modifying the
.vimrcfile), and there are countless resources on the Internet to learn from. - If you want to know more about how to customize Vim to suit your needs, Learn Vim Script the Hard Way is a perfect start point.
Remapping Keys
Ctrl and Esc keys are probably two of the most used keys in Vim. However, these two keys are pretty far away from home row. In order to make it easier to reach these keys, you can remap CapsLock to Esc or Ctrl.
On Windows, Powertoys or AutoHotkey can be used to achieve this goal.
On macOS, you can remap keys in system settings, see this page.
A better solution is to make CapsLock function as Esc and Ctrl simultaneously. Click CapsLock to send Esc, hold CapsLock to use it as Ctrl key.
On Windows, this AutoHotKey gist does just this.
On macOS, this karabiner rule does the magic.
Recommended References
- Neil, Drew. Practical Vim: Edit Text at the Speed of Thought. N.p., Pragmatic Bookshelf, 2015.
- Neil, Drew. Modern Vim: Craft Your Development Environment with Vim 8 and Neovim. United States, Pragmatic Bookshelf.
Vim
为什么学习 Vim
在我看来 Vim 编辑器有如下的好处:
- 让你的整个开发过程手指不需要离开键盘,而且光标的移动不需要方向键使得你的手指一直处在打字的最佳位置。
- 方便的文件切换以及面板控制可以让你同时开发多份文件甚至同一个文件的不同位置。
- Vim 的宏操作可以批量化处理重复操作(例如多行 tab,批量加双引号等等)
- Vim 是很多服务器自带的命令行编辑器,当你通过
ssh连接远程服务器之后,由于没有图形界面,只能在命令行里进行开发(当然现在很多 IDE 如 VS Code 提供了ssh插件可以解决这个问题)。 - 异常丰富的插件生态,让你拥有世界上最花里胡哨的命令行编辑器。
如何学习 Vim
不幸的是 Vim 的学习曲线确实相当陡峭,我花了好几个星期才慢慢适应了用 Vim 进行开发的过程。最开始你会觉得非常不适应,但一旦熬过了初始阶段,相信我,你会爱上 Vim。
Vim 的学习资料浩如烟海,但掌握它最好的方式还是将它用在日常的开发过程中,而不是一上来就去学各种花里胡哨的高级 Vim 技巧。个人推荐的学习路线如下:
- 先阅读这篇 tutorial,掌握基本的 Vim 概念和使用方式。
- 用 Vim 自带的
vimtutor进行练习,安装完 Vim 之后直接在命令行里输入vimtutor即可进入练习程序。 - 最后就是强迫自己使用 Vim 进行开发,IDE 里可以安装 Vim 插件。
- 等你完全适应 Vim 之后新的世界便向你敞开了大门,你可以按需配置自己的 Vim(修改
.vimrc文件),网上有数不胜数的资源可以借鉴。
推荐参考资料
- Neil, Drew. Practical Vim: Edit Text at the Speed of Thought. N.p., Pragmatic Bookshelf, 2015.
- Neil, Drew. Modern Vim: Craft Your Development Environment with Vim 8 and Neovim. United States, Pragmatic Bookshelf.
Vim
为什么学习 Vim
在我看来 Vim 编辑器有如下的好处:
- 让你的整个开发过程手指不需要离开键盘,而且光标的移动不需要方向键使得你的手指一直处在打字的最佳位置。
- 方便的文件切换以及面板控制可以让你同时开发多份文件甚至同一个文件的不同位置。
- Vim 的宏操作可以批量化处理重复操作(例如多行 tab,批量加双引号等等)
- Vim 是很多服务器自带的命令行编辑器,当你通过
ssh连接远程服务器之后,由于没有图形界面,只能在命令行里进行开发(当然现在很多 IDE 如 VS Code 提供了ssh插件可以解决这个问题)。 - 异常丰富的插件生态,让你拥有世界上最花里胡哨的命令行编辑器。
如何学习 Vim
不幸的是 Vim 的学习曲线确实相当陡峭,我花了好几个星期才慢慢适应了用 Vim 进行开发的过程。最开始你会觉得非常不适应,但一旦熬过了初始阶段,相信我,你会爱上 Vim。
Vim 的学习资料浩如烟海,但掌握它最好的方式还是将它用在日常的开发过程中,而不是一上来就去学各种花里胡哨的高级 Vim 技巧。个人推荐的学习路线如下:
- 先阅读这篇 tutorial,掌握基本的 Vim 概念和使用方式。
- 用 Vim 自带的
vimtutor进行练习,安装完 Vim 之后直接在命令行里输入vimtutor即可进入练习程序。 - 最后就是强迫自己使用 Vim 进行开发,IDE 里可以安装 Vim 插件。
- 等你完全适应 Vim 之后新的世界便向你敞开了大门,你可以按需配置自己的 Vim(修改
.vimrc文件),网上有数不胜数的资源可以借鉴。 - 如果你想对配置 Vim 有更加深入的了解,Learn Vim Script the Hard Way 是一个很好的资源。
关于键位映射
用 Vim 编辑代码的时候会频繁用到 ESC 和 CTRL 键, 但是这两个键都离 home row 很远, 可以把 CapsLock 键映射到 Esc 或者 Ctrl 键,让手更舒服一些。
Windows 系统可以使用 Powertoys 或者 AutoHotkey 重映射键位。
MacOS 系统提供了重映射键位的设置,另外也可以使用 Karabiner-Elements 重映射。
但更佳的做法是同时将 CapsLock 映射为 Ctrl 和 Esc,点按为 Esc,按住为 Ctrl。
Windows 系统下,这个AutoHotKey gist 实现了这个功能。
MacOS 可以导入这个 karabiner rule 重映射。
推荐参考资料
- Neil, Drew. Practical Vim: Edit Text at the Speed of Thought. N.p., Pragmatic Bookshelf, 2015.
- Neil, Drew. Modern Vim: Craft Your Development Environment with Vim 8 and Neovim. United States, Pragmatic Bookshelf.
Vim
为什么学习 Vim
在我看来 Vim 编辑器有如下的好处:
- 让你的整个开发过程手指不需要离开键盘,而且光标的移动不需要方向键使得你的手指一直处在打字的最佳位置。
- 方便的文件切换以及面板控制可以让你同时开发多份文件甚至同一个文件的不同位置。
- Vim 的宏操作可以批量化处理重复操作(例如多行 tab,批量加双引号等等)
- Vim 是很多服务器自带的命令行编辑器,当你通过
ssh连接远程服务器之后,由于没有图形界面,只能在命令行里进行开发(当然现在很多 IDE 如 VS Code 提供了ssh插件可以解决这个问题)。 - 异常丰富的插件生态,让你拥有世界上最花里胡哨的命令行编辑器。
如何学习 Vim
不幸的是 Vim 的学习曲线确实相当陡峭,我花了好几个星期才慢慢适应了用 Vim 进行开发的过程。最开始你会觉得非常不适应,但一旦熬过了初始阶段,相信我,你会爱上 Vim。
Vim 的学习资料浩如烟海,但掌握它最好的方式还是将它用在日常的开发过程中,而不是一上来就去学各种花里胡哨的高级 Vim 技巧。个人推荐的学习路线如下:
- 先阅读这篇 tutorial,掌握基本的 Vim 概念和使用方式。
- 用 Vim 自带的
vimtutor进行练习,安装完 Vim 之后直接在命令行里输入vimtutor即可进入练习程序。 - 最后就是强迫自己使用 Vim 进行开发,IDE 里可以安装 Vim 插件。
- 等你完全适应 Vim 之后新的世界便向你敞开了大门,你可以按需配置自己的 Vim(修改
.vimrc文件),网上有数不胜数的资源可以借鉴。
推荐参考资料
- Neil, Drew. Practical Vim: Edit Text at the Speed of Thought. N.p., Pragmatic Bookshelf, 2015.
- Neil, Drew. Modern Vim: Craft Your Development Environment with Vim 8 and Neovim. United States, Pragmatic Bookshelf.
Vim
为什么学习 Vim
在我看来 Vim 编辑器有如下的好处:
- 让你的整个开发过程手指不需要离开键盘,而且光标的移动不需要方向键使得你的手指一直处在打字的最佳位置。
- 方便的文件切换以及面板控制可以让你同时开发多份文件甚至同一个文件的不同位置。
- Vim 的宏操作可以批量化处理重复操作(例如多行 tab,批量加双引号等等)
- Vim 是很多服务器自带的命令行编辑器,当你通过
ssh连接远程服务器之后,由于没有图形界面,只能在命令行里进行开发(当然现在很多 IDE 如 VS Code 提供了ssh插件可以解决这个问题)。 - 异常丰富的插件生态,让你拥有世界上最花里胡哨的命令行编辑器。
如何学习 Vim
不幸的是 Vim 的学习曲线确实相当陡峭,我花了好几个星期才慢慢适应了用 Vim 进行开发的过程。最开始你会觉得非常不适应,但一旦熬过了初始阶段,相信我,你会爱上 Vim。
Vim 的学习资料浩如烟海,但掌握它最好的方式还是将它用在日常的开发过程中,而不是一上来就去学各种花里胡哨的高级 Vim 技巧。个人推荐的学习路线如下:
- 先阅读这篇 tutorial,掌握基本的 Vim 概念和使用方式。
- 用 Vim 自带的
vimtutor进行练习,安装完 Vim 之后直接在命令行里输入vimtutor即可进入练习程序。 - 最后就是强迫自己使用 Vim 进行开发,IDE 里可以安装 Vim 插件。
- 等你完全适应 Vim 之后新的世界便向你敞开了大门,你可以按需配置自己的 Vim(修改
.vimrc文件),网上有数不胜数的资源可以借鉴。 - 如果你想对配置 Vim 有更加深入的了解,Learn Vim Script the Hard Way 是一个很好的资源。
关于键位映射
用 Vim 编辑代码的时候会频繁用到 ESC 和 CTRL 键, 但是这两个键都离 home row 很远, 可以把 CapsLock 键映射到 Esc 或者 Ctrl 键,让手更舒服一些。
Windows 系统可以使用 Powertoys 或者 AutoHotkey 重映射键位。
MacOS 系统提供了重映射键位的设置,另外也可以使用 Karabiner-Elements 重映射。
但更佳的做法是同时将 CapsLock 映射为 Ctrl 和 Esc,点按为 Esc,按住为 Ctrl。
Windows 系统下,这个AutoHotKey gist 实现了这个功能。
MacOS 可以导入这个 karabiner rule 重映射。
推荐参考资料
- Neil, Drew. Practical Vim: Edit Text at the Speed of Thought. N.p., Pragmatic Bookshelf, 2015.
- Neil, Drew. Modern Vim: Craft Your Development Environment with Vim 8 and Neovim. United States, Pragmatic Bookshelf.