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

推荐订阅源

WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
腾讯CDC
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
N
Netflix TechBlog - Medium
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
GbyAI
GbyAI
B
Blog
F
Fortinet All Blogs
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
Google Developers Blog
A
About on SuperTechFans
C
Check Point Blog
Microsoft Security Blog
Microsoft Security Blog
MyScale Blog
MyScale Blog
B
Blog RSS Feed

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
Nifty Nvim/Vim Techniques That Make My Life Easier -- Ser...
2020-11-11 · via jdhao's digital space

This is the 8th post of my post series on nifty Nvim/Vim techniques that will make my editing experience easier.

Click here to check other posts in this series.

Use Neovim as man pager#

The default pager used by man command on *nix lacks syntax highlighting and is not good for reading, searching. Why not turn nvim into the man pager? Just add the following setting to your shell config file:

if [[ "$(command -v nvim)" ]]; then
    export EDITOR='nvim'
    export MANPAGER='nvim +Man!'
    export MANWIDTH=999
fi

See also :h man.vim.

Ref:

Close other windows quickly?#

When we are in a certain window, we may want to close all other windows. We may go to the other windows and close them with :quit. It is a bit cumbersome.

The :only command is a much nicer way. It will close all the other windows except the one we are in. There is also an equivalent shortcut: <C-W> o (that is, Ctrl-W, followed by o).

Ref:

Execute a macro in several lines.#

Macro is a powerful way to edit texts with similar structures. To execute a macro on several lines, we can use a line range if the lines are continuous. For example, execute macro a for line 10 to 15, use:

Or we can visually select the lines, and run the following command (note that if you select these lines, and then press :, Nvim will insert '<,'> automatically):

To execute a macro only on lines matching a certain pattern, run the following command:

Ref:

Copy URL under cursor into a register?#

We can use <cfile> with expand() function get the URL under cursor (see :h <cfile>). To copy the URL to unnamed register, use the following command:

let @" = expand('<cfile>')

The above method is not perfect, since expand('<cfile>') will also give you results even if your cursor is on a normal words (non-URL).

A more sophisticated method would be using actual URL patterns and search the current line to get a valid URL. A good URL pattern is provided by plugin vim-highlighturl via highlighturl#default_pattern() method. With this knowledge, here is a more error-proof approach to get the current URL:

let @" = matchstr(getline('.'), highlighturl#default_pattern())

Ref:

Get diff between two buffers or files#

If we have two different versions of the same file and we want to find the differences between them, how do we do it inside Neovim?

Suppose the two files are manual-v1.md, manual-v2.md, here is how to compare them inside Neovim.

If you haven’t start Nvim, you can run the following command:

nvim -d manual-v1.md manual-v2.md

This will start nvim in diff mode.

If you are already inside Neovim, first open manual-v1.md (:e manual-v1.md), then open manual-v2.md in a vertical split window (:vs manual-v2.md)1. Finally, run the following command to start comparing:

Ref: