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

推荐订阅源

M
MIT News - Artificial intelligence
有赞技术团队
有赞技术团队
S
Schneier on Security
aimingoo的专栏
aimingoo的专栏
T
Troy Hunt's Blog
U
Unit 42
Hacker News - Newest:
Hacker News - Newest: "LLM"
V2EX - 技术
V2EX - 技术
T
The Blog of Author Tim Ferriss
V
Visual Studio Blog
H
Heimdal Security Blog
H
Hacker News: Front Page
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Cloudbric
Cloudbric
Google DeepMind News
Google DeepMind News
C
Cisco Blogs
The Cloudflare Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
MyScale Blog
MyScale Blog
F
Fortinet All Blogs
N
News | PayPal Newsroom
Attack and Defense Labs
Attack and Defense Labs
D
DataBreaches.Net
N
News and Events Feed by Topic
Security Archives - TechRepublic
Security Archives - TechRepublic
Forbes - Security
Forbes - Security
Simon Willison's Weblog
Simon Willison's Weblog
F
Full Disclosure
The Register - Security
The Register - Security
L
LINUX DO - 热门话题
Webroot Blog
Webroot Blog
Google Online Security Blog
Google Online Security Blog
AI
AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
I
Intezer
S
Security Affairs
阮一峰的网络日志
阮一峰的网络日志
K
Kaspersky official blog
云风的 BLOG
云风的 BLOG
博客园 - 叶小钗
T
Threatpost
Spread Privacy
Spread Privacy
小众软件
小众软件
AWS News Blog
AWS News Blog
S
Secure Thoughts
S
Security @ Cisco Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN Mintty Tips and Configurations Generating Table of Contents for Markdown with Tagbar Convert Python Script to Exe on Windows with Pyinstaller Ubuntu on Windows Missing after Windows Update 使用代理加速 Mac 终端下载速度 My Experience with Several Zsh Plugin Managers 深圳租房小记 How to Install zplug inside Docker Container Why don't settings inside bashrc or bash_profile take effect? Setting Up Locale in Linux 谷歌 Adsense 申请及在 Hugo 中的配置 How to Write Algorithm Pseudo Code in LaTeX Nifty Nvim Techniques That Make My Life Easier -- Series 4 A Few Grammar Questions in Writing How to Read and Write Images with Unicode Paths in OpenCV Creating A Professional Table in LaTeX with booktabs How to Create Proper Folding for Vim/Nvim Configuration Linux Tips and Tricks -- s1 JPEG Image Orientation and Exif How Do I Show the Current File Path In Neovim? JPEG Image Quality in PIL Difference between view, reshape, transpose and permute in PyTorch Convert PIL or OpenCV Image to Bytes without Saving to Disk Fast Movement and Navigation Inside Vim or Neovim Unintuitive Behaviour of Case Sensitivity in Python glob Binding Keys in Zsh 几把机械键盘试用体验 Nvim Autocompletion with Deoplete Converting Markdown to Beautiful PDF with Pandoc Exclusive and Inclusive Motion in Neovim/Vim Nifty Nvim Techniques Which Make My Life Easier -- Series 3 Why Doesn't Jedi Autocompletion Work for Some Methods Vim-like Editing inside Browser Markdown 生成 HTML 时汉字之间出现多余空格问题 小米 9 安装谷歌商店(Google Play Store)与相关配置 Create Mappings That Take A Count in Neovim Spell Checking in Nvim English Words Completion inside Neovim/Vim How to Use Python Inside Vim Script with Neovim Nifty Little Nvim Techniques to Make My Life Easier -- Series 2 Setting up Ultisnips for Neovim Mac 上罗技 M590 鼠标设置 Nifty Little Nvim Techniques to Make My Life Easier -- Series 1 A Complete Guide on Writing LaTeX with Vimtex in Neovim Manipulating Images with Alpha Channels in Pillow Sublime Text Regular Expression Cheat Sheet Cropping Rotated Rectangles from Image with OpenCV Boosting Your Productivity on Terminal with Zsh and Plugins 最新版 Rime 输入法使用 (2022 更新) Display Image with Pillow inside Ubuntu on Windows Faster Directory Navigation with z.lua Cmder Advanced Configurations Nvim-qt Settings on Windows 10 Tmux Plugin Install and Management How to Debug Python Code in Terminal Markdown Writing and Previewing in Neovim -- A Complete Guide Line Number Settings for More Efficient Movement in Neovim 两个大规模中文语料库介绍以及处理 Windows 系统下几款程序员不可不用的神器 我的 2018 阅读清单 A Complete Guide to Neovim Configuration for Python Development How Is Newline Handled in Python and Various Editors? Two Issues Related to ImageFont Module in PIL 在 Listary 中调用 GoldenDict 或欧路词典查单词 Reading and Writing Text Files on Windows The Mathematics behind Font Shapes --- Bézier Curves and More 快速识别图片字体:字体识别工具介绍 Deoplete Failed to Load at Startup after Updating Python neovim Package What Is The Difference between pip, pip3 and pip3.6 Shipped with Anaconda3? How to Use shutil.move() on Windows and Linux
Windows 10 系统下 Neovim 安装与配置
2018-11-16 · 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,添加如下的配置:

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

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

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

Press ENTER or type command to continue

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

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

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

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-^:

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

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

参考链接#