虽然我们可以在终端使用 Vim,但如果能通过 GUI 来使用 Vim 的能力,一定能大大提高效率。这里就推荐一款 Vim 的 GUI 工具:VimR。
VimR 的目标正如项目描述的:
❝
The goal is to build an editor that uses Neovim inside with many of the convenience GUI features similar to those present in modern editors.
❞
即构建一个在内部使用 Neovim 的编辑器,并具有与现代编辑器类似的许多便捷 GUI 功能。
特性
VimR 具有一些不错的特性,如:
-
Markdown 预览 -
通用 HTML 预览(重新加载时保留滚动位置) -
模糊文件查找器,如 Xcode 的“快速打开……” -
基本触控板支持:缩放和两指滚动捏合 -
支持连字:默认关闭。在首选项中打开它 -
表情符号支持 -
基本文件和编辑菜单项 -
支持命令行工具 -
简单的文件浏览器 -
灵活的工作空间模型,类似于 JetBrain 的 IDE
另外,VimR 有一个很酷的特点是自适应主题。当我们改变配色方案时,VimR 会改变 UI 以匹配。
正如上面清单中描述的,VimR 借鉴了 Jetbrain 的灵活工作空间。可以根据自己的喜好移动四个侧边栏选项(文件、缓冲区、HTML 和 Markdown)。这允许垂直或水平查看。
使用
VimR 的安装很简单,从 Github 上下载 release 安装即可。下面是一些基础的配置和使用。
基础配置
在使用 VimR 之前,我们可能需要检查 init.vim
中的 gui_vimr
标志以将某些设置仅应用于 VimR:
if has("gui_vimr")
" Here goes some VimR specific settings like
color xyz
endif
或者我们可以将 VimR 的特定设置放在 ~/.config/nvim/ginit.vim
中。
实时窗口调整大小
实时窗口大小调整默认关闭。我们可以在 Advanced Preferences
中打开它:
连字
默认情况下关闭连字。可以在 Appearance Preferences
中打开它:
自定义键盘快捷键
我们可以在 Shortcuts Preferences
中更改菜单项的快捷方式:
自定义快捷方式将显示为蓝色。
Neovim 内部的命令
我们可以使用以下命令来控制一些 GUI 元素:
-
VimRMaximizeWindow -
VimRToggleFullscreen -
VimRHideTools, VimRToggleTools, VimRShowTools -
VimRHideToolButtons, VimRToggleToolButtons, VimRShowToolButtons -
VimRMakeSessionTemporary:VimR 不存储 GUI 设置,例如 窗口大小、工具和工具按钮的可见性。 -
VimRSetFontAndSize "Some Font Name", 13
:将字体和大小分别设置为 Some Font Name 和 13。大小必须是整数。 -
VimRSetLinespacing 1.0
:设置行距为 1.0。该值必须是浮点数。
如果我们想在启动过程中执行其中一些命令,必须将它们放在 ~/.config/nvim/ginit.vim
中。
滚动和渲染性能
我们可以在 Advanced Preferences
中打开字形的并发计算。根据情况,这可能会让渲染更快。但是,也会导致更高的 CPU 使用率。
VimR 中的 $PATH
确保环境变量 SHELL 设置为合理的值:VimR 使用 SHELL 启动 Neovim 后台进程。
命令行工具
VimR 带有一个命令行工具 vimr:
$ vimr --help
usage: vimr [-h] [--dry-run] [--cwd CWD] [--line LINE] [--wait] [--nvim]
[--cur-env | -n | -s]
[file [file ...]]
Open files in VimR: By default all files are open in tabs in the front most
window or in a new window if there is none. The working directory will be set
to the current directory.
positional arguments:
file
optional arguments:
-h, --help show this help message and exit
--dry-run Just print the 'open' command.
--cwd CWD Set the working directory.
--line LINE Go to line
--wait This command line tool will exit when the corresponding UI
window is closed.
--nvim All arguments except --cur-env, --line, --dry-run and --wait
will be passed over to the (new) nvim instance in a new UI
window.
--cur-env Use the current environment variables when launching the
background neovim process. All files will be opened in a new
window.
-n Open files in tabs in a new window.
-s Open files in separate windows.
例如,要将 VimR 用作 git difftool
,请将以下内容添加到您的 ~/.gitconfig
[difftool "vimrdiff"]
cmd = vimr --wait --nvim -d $LOCAL $REMOTE
[diff]
tool = vimrdiff
它可以通过 Preferences ➝ General ➝ "Copy 'vimr' CLI tool..."
按钮安装:
小结
Vim 的 GUI 方案还有不少,有不少是基于 Electron 的,这些相对来说性能都比较一般。而 VimR 是基于 Swift 和 macOS 原生体系来构建的,值得一试。
❝
「VimR」
地址:https://github.com/qvacua/vimr
⭐️:6.1k
语言:Swift
❞
原文始发于微信公众号(小集):macOS 上一款杀手级的 Vim GUI 工具
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/215311.html