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

推荐订阅源

aimingoo的专栏
aimingoo的专栏
宝玉的分享
宝玉的分享
博客园 - 【当耐特】
博客园 - 司徒正美
L
LangChain Blog
有赞技术团队
有赞技术团队
大猫的无限游戏
大猫的无限游戏
Stack Overflow Blog
Stack Overflow Blog
Engineering at Meta
Engineering at Meta
U
Unit 42
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
博客园 - 叶小钗
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
月光博客
月光博客
量子位
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园_首页
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
Google DeepMind News
Google DeepMind News
云风的 BLOG
云风的 BLOG
D
DataBreaches.Net

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...
2021-06-17 · via jdhao's digital space

This is the 10th 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.

Equal sign (=) is recognized as part of file name#

I have a config file where it has a line like file_path=path/to/file.txt. When the cursor is after the = sign, I tried to use gf to open the file path/to/file.txt. I got the following error:

E447: Can’t find file “file_path=path/to/file.txt” in path.

Apparently, Vim thinks that = is part of the file name and tries to open the wrong file. It turns out that gf is using the option isfname to decide which character is valid for a file name. So we need to remove = from this option.

Open a buffer in vertical split#

There are several ways to do this:

  • :vsplit +b{count}: {count} represents the buffer number, as shown by :ls or :buffers command.
  • :vsplit #{count}: {count} has the same meaning as above.
  • :vert sb {count}: {count} has the same meaning as above.
  • :vert sb {buf_name}: {buf_name} represents the path to a file. It supports completion for buffer names, i.e., you only need to type part of the path and then press <Tab> for completion.

Ref:

Disable syntax highlighting for a particular filetype#

When we open a YAML file using Neovim, if the file has thousands of lines, cursor movement will be slowed down considerably due to Vim’s slow syntax highlighting feature. In this case, we may want to turn syntax highlight off for YAML based on its line numbers. We can use FileType autocmd to detect the file type and set the syntax option to disable syntax highlighting.

augroup yaml_syntax_off
   autocmd!
   autocmd FileType yaml if line('$') > 500 | setlocal syntax=OFF | endif
augroup END

Note that we use setlocal syntax=OFF instead of syntax off, because syntax off will turn off syntax highlight for all the buffers currently opened, which is not what we want.

Ref:

I get error when I try to call a plugin function in init.vim?#

I want to call a plugin’s function in my init.vim, but I get an error that the function does not exist? However, when nvim is opened, I call the function without any errors. What happened?

The called function is in a script under plugin directory. This is because the plugin has not been properly initialized. We can call the plugin function after VimEnter event:

autocmd VimEnter * call my_plugin_func()

Ref:

Generate a list of incrementing numbers one per line#

I would like to generate a list of incrementing numbers:

How do we do it in Vim? First, generate a list of same numbers. Input 0 in the first line, press yy and then press 4p to generate five zeros:

Then move the cursor to first 0, and press Ctrl-V, followed by 4j to visual select this block. Finally, press g, followed by pressing Ctrl-A. We will get what we want.

Another way is to use :put command: :put =range(1, 5), which is more concise.

Ref: