惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

SecWiki News
SecWiki News
I
InfoQ
The Cloudflare Blog
人人都是产品经理
人人都是产品经理
博客园 - Franky
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
量子位
博客园_首页
罗磊的独立博客
V
V2EX
李成银的技术随笔
大猫的无限游戏
大猫的无限游戏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
True Tiger Recordings
Vercel News
Vercel News
Cyberwarzone
Cyberwarzone
Cisco Talos Blog
Cisco Talos Blog
F
Fox-IT International blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
M
Microsoft Research Blog - Microsoft Research
Know Your Adversary
Know Your Adversary
爱范儿
爱范儿
The Register - Security
The Register - Security
G
Google Developers Blog
The Hacker News
The Hacker News
Malwarebytes
Malwarebytes
S
Securelist
博客园 - 三生石上(FineUI控件)
Jina AI
Jina AI
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
S
SegmentFault 最新的问题
博客园 - 叶小钗
F
Fortinet All Blogs
Apple Machine Learning Research
Apple Machine Learning Research
宝玉的分享
宝玉的分享
博客园 - 聂微东
T
Threatpost
博客园 - 【当耐特】
D
Docker
P
Privacy & Cybersecurity Law Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
V
Visual Studio Blog
C
Cisco Blogs
IT之家
IT之家
S
Security Archives - TechRepublic
Latest news
Latest news
阮一峰的网络日志
阮一峰的网络日志

jdhao's digital space

Manage uv.lock file with Renovate Set up Python Provider for Neovim Ripgrep Config to Search Hidden Files Pre-commit Setup for Your Project I read the nvim v0.12 release note so you don't have to Return Different Values for Each Call of A Mock Migrate Python Project from Pip to Uv 德语常用不规则动词 葱油鸡腿制作 Check Trailing White Spaces in Your Project 菜谱:茄子肉丁 object vs nested type in data mapping in Elasticsearch Node, Index, Shard in Elasticsearch Logging setup for Pytest Select fields in Elasticsearch: _source, fields and stored_fields 中式葱花饼制作 菜谱: 凉拌苤蓝(卜留克/kohlrabi) 我也有高考 PTSD Garmin Course Syncing Not Working? Prevent Accidental Index Delete in Elasticsearch How to Import GPX File into Garmin Watch Python system PATH issues When We Use Pytest 菜谱:泰式打抛牛肉 菜谱:烤箱羊肉串 How to Filter Warnings in Python/pytest 家常烤箱烤鸡腿 Comparison between Several Desktop Speakers How to Use LuaRocks Package in Neovim Macbook 外接显示器 家常萝卜炖羊排 Run the Job Immediately after Starting Scheduler in Python APScheduler Retry for Google Cloud Client 菜谱:土豆金枪鱼沙拉 菜谱:椰香咖喱鸡 凉拌绿豆宽粉制作 Make Python logging Work in GCP Liveness and Readiness Check in Kubernetes Notes on Using GCP Logging 西班牙土豆饼制作 Elasticsearch Version Conflict Error How to Use the Elasticsearch task API Speed up document indexing in Elasticsearch via bulk indexing Index refresh issue in Elasticsearch Google Cloud Storage Usage 家常煎羊排制作 凉拌茄子制作 Configure Python logging with dictConfig Debugging Wezterm Issues Black Formatter Setup for Python Project Git line ending config Garmin Forerunner 965 Essential Tips and Setups How to Download Files from Google Cloud Storage in the Databricks Workspace Notebook Databricks Cli Usage Working with Databricks Workspace Files 手抓羊肉饭制作 Databricks Init Scripts Using Virutal Environment in Python with venv File Systems in Databricks LATERAL VIEW EXPLODE in Spark 菜谱:麻婆豆腐 在德国做台湾卤肉饭 FastAPI testing and OpenAPI doc generation Change Timezone in Databricks Spark How to Profile Your Python Script/Module 菜谱:茄子肉沫 Migrating from Packer.nvim to Lazy.nvim How to Extract PDF file on macOS How to Deploy Fastapi Application with Docker Nerdfont Icon Missing after Wezterm Upgrade Pylsp setup for Neovim in 2023 How to Parse Query Param With Multiple Values in FastAPI 菜谱:土豆胡萝卜烧牛肉 Zsh Startup Files in macOS PATH Variable Changed inside Tmux on macOS? Work with JSON File in Neovim Running/importing Python code/module in Databricks Agile and Scrum 菜谱:凉拌牛肉 Awesome Command Line Tools Written in Rust How to get or set Databricks spark configuration Set Up German Version macOS Add A Custom Search Engine for Vimium 中国大陆小米手机如何使用 Google Pay 春节回乡记 滇西之行 2023 贵阳行 2023 程序员海外工作---语言篇 2023 长沙行 2023 西安行 德国工签申请指南 2022 年博客回顾 感染 omicron 记录 How to Override Default Options in Neovim Variadic Arguments in Lua How to Enable Method Autocompletion for OpenCV How to Read Local CSV File to Table in MySQL I read the nvim v0.8 release note so you do not have to Creating A Trigger in PostgreSQL Cost of Living in Shenzhen You Do Not Need a Plugin for This Feature
Windows 10 系统下 Neovim 安装与配置
2018-11-15 · via jdhao's digital space

本篇文章介绍如何在 Windows 系统下安装并配置终端上的 Neovim。关于如何配置 Neovim 的 GUI 客户端 nvim-qt,可以参考 这篇博客

TL;DR: 长时间在 Windows 使用 Neovim 编程以后,我认为要在 Windows 上获得使用 Neovim 的最佳体验,必须使用 GUI 客户端(使用 GUI 客户端能避免很多小问题),而不是在终端命令行使用 Neovim。另外,Windows 系统下一些不错的 GUI 客户端有 Nvim-qtfvim(新出来的一个客户端,体验不错)。

开始之前#

Windows 自带的 CMD 命令行非常糟糕,不仅颜色难看,而且缺乏许多常用的 Linux 命令。不建议使用 CMD 作为命令行终端,建议使用 Cmder。Cmder 安装的时候,也附带安装了 Git for Windows 和其他的一些工具,可以使用 Linux 下的常用命令,如 ls, find, pwd 等等。

Neovim 针对各个系统均有编译好的安装包,用户无需自己编译,省去了大量配置时间,安装非常方便。从 这里 可以下载到 Neovim win-64 位安装包,直接解压安装包即可完成安装。另外,需要把 Neovim 可执行程序所在的目录添加到系统的 PATH 中,确保在命令行可以使用 nvim 这个命令打开 Neovim。

当然也可以用 Chocolatey 或者 scoop 等包管理工具安装 Neovim,具体可以参考 这里 的说明。

配置#

配置文件应该放在哪里?#

Neovim 使用了和 Vim 不同的配置文件名称以及配置文件存放位置,根据 Neovim 官方文档,Neovim 的配置文件应该命名为 init.vim,并且应该放在 ~/AppData/Local/nvim 目录下1

安装插件管理器 vim-plug#

Vim-plug 是一个不错的插件管理器,要安装 vim-plug,首先打开 PowerShell 窗口,然后执行以下的命令:

md ~\AppData\Local\nvim\autoload
$uri = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
(New-Object Net.WebClient).DownloadFile(
  $uri,
  $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(
    "~\AppData\Local\nvim\autoload\plug.vim"
  )
)

在 Neovim 的配置文件中,使用如下的 vim-plug 示例配置:

call plug#begin('~/AppData/Local/nvim/plugged')
" below are some vim plugin for demonstration purpose
Plug 'joshdick/onedark.vim'
Plug 'iCyMind/NeoSolarized'

Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
call plug#end()

打开 Neovim,然后运行 :PlugInstall 命令,所有要安装的插件都会被安装到目录 ~/AppData/Local/nvim/plugged 下. 当然,你可以根据自己的实际需求,更改插件安装的目录。

问题及解决方案#

退出 Neovim 窗口的时候,buffer 里面的内容未清空#

在命令行使用 Neovim 时,当退出 Neovim 窗口,原来的窗口里面的文字内容仍然显示在命令行,并未被清空,浪费了大量的空间。这和 Neovim 在 Linux 下的表现不相同,如何在退出 Neovim 以后自动清除这些文字内容呢?

经过一番搜索,我发现了一个对 Cmder 有效的解决方法。打开 Cmder 的配置,找到 Startup -> Environment,添加如下的配置:

set TERM=xterm-256color

重启 Cmder,以上的问题应该就消失了。更多讨论,参见这里.

当配置文件出错时,无法进入 Neovim 窗口#

在命令使用 Neovim,如果配置文件某行设置有错,在打开 Neovim 时,我们会收到如下提示:

Press ENTER or type command to continue

然而,如果我们按下 Enter,Neovim 也不会启动。Neovim 程序会卡死在那里,除非你使用 Ctrl+ C 强行关闭这个进程。

为了避免这个问题,根据 这里 的回答,可以使用以下命令启动 Neovim:

nvim --cmd silent!

一些快捷键无法正常工作#

Neovim 和 Cmder 的快捷键冲突#

部分原因是 Neovim 和 Cmder 的某些快捷键有冲突,例如在 Cmder 中,Ctrl-W 用来关闭一个 console 窗口。但是 Ctrl-W 在 Neovim 被用于和窗口相关的操作。可能还存在其他有冲突的快捷键,例如 Ctrl-v 无法像 Linux 下那样工作

要禁止 Cmder 中和 Neovim 冲突的快捷键,可以在设置的 Keys & Macro 部分更改或者禁止那些冲突的快捷键,

<Ctrl-6> 无法工作?#

在 Linux 或者 Mac 下,我们可以使用 Ctrl-^(实际上是Ctrl-6) 来切换 Neovim 的 buffer,但是在 Windows Cmder 命令行下面,我发现 <Ctrl-6> 不起作用,按下以后也无法切换 buffer。我试着把 Ctrl-6 映射为 Ctrl-^:

nnoremap <C-6> <C-^>

还是不起作用。目前暂时使用 Ctrl+shift+6 来切换 buffer。

我的完整 Neovim 配置可以在 这里 查看。关于如何配置 Neovim Python 开发环境,可以看 这篇文章

参考链接#


  1. 打开 Neovim,使用 :echo stdpath('config') 可以查看该目录的具体位置。 ↩︎