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

推荐订阅源

P
Proofpoint News Feed
T
Troy Hunt's Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
CXSECURITY Database RSS Feed - CXSecurity.com
小众软件
小众软件
S
Securelist
The Cloudflare Blog
博客园 - 司徒正美
D
Darknet – Hacking Tools, Hacker News & Cyber Security
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
博客园 - Franky
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Latest news
Latest news
V
Vulnerabilities – Threatpost
雷峰网
雷峰网
G
GRAHAM CLULEY
罗磊的独立博客
J
Java Code Geeks
C
Cisco Blogs
Scott Helme
Scott Helme
Spread Privacy
Spread Privacy
宝玉的分享
宝玉的分享
T
The Blog of Author Tim Ferriss
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Azure Blog
Microsoft Azure Blog
T
Tor Project blog
GbyAI
GbyAI
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
博客园_首页
D
DataBreaches.Net
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Stack Overflow Blog
Stack Overflow Blog
K
Kaspersky official blog
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed
aimingoo的专栏
aimingoo的专栏
SecWiki News
SecWiki News
V
Visual Studio Blog
Jina AI
Jina AI
S
Schneier on Security
T
Threat Research - Cisco Blogs
Project Zero
Project Zero
有赞技术团队
有赞技术团队
P
Privacy & Cybersecurity Law Blog
Help Net Security
Help Net Security

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 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? Windows 10 系统下 Neovim 安装与配置 How to Use shutil.move() on Windows and Linux
Nifty Nvim Techniques Which Make My Life Easier -- Series 3
2019-05-14 · via jdhao's digital space

This is the 3rd 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.

How do I use last search pattern in substitute command?#

As is often the case, when we want to replace some patterns, we may not be able to write the correct regular expression in one pass and have to refine it many times. I often search first to make sure that the search pattern is correct. Then I manually type the search pattern again in substitute command to replace it with the text I want. This is acceptable when the pattern is simple to type. It becomes unacceptable once the search patterns are complicated.

To use the last search pattern, you can keep the search part empty in substitute command, e.g., %s//REPLACE/g, which will replace all occurrences of last search pattern with REPLACE. Alternatively, you could use <C-R>/ to input your last search pattern, that is, first press Ctrl+ R and then press /1.

References#

How do I write the output of a command or built-in function to a buffer?#

A least three ways are possible (take function strftime() and command :scriptnames (:h :scriptnames) for an example).

  1. Use <C-R>= in insert mode. In insert mode, press Ctrl+R followed by =, then type the function (e.g., strftime('%c')) or use execute() to run a command (e.g., execute('scriptnames')). The output will inserted right after the current cursor.

  2. Use :put= in command mode. In command mode, first input put=, then input the function or execute() command. The output will be put below the current cursor line.

  3. Use redir. We first use redir to redirect the output to a Vim register and then paste the content of the register to current buffer. For functions, use the following

    :redir @a | echo strftime('%c') | redir END<CR>

    For commands, use:

    :redir @a | silent scriptnames |redir END<CR>

    This will redirect the output of function strftime() or command scriptnames to register a. To paste the content of register a, use "ap in normal mode.

    You can also directly redirect the output to current file:

    :redir >> % | silent scriptnames|redir END|edit

    , which may be more convenient sometimes.

  4. Use let with a register. This is similar to using redir, but more concise. For function outputs, use:

    :let @a = strftime("%c")<CR>

    For command outpus, use:

    :let @a = execute("silent scriptnames")<CR>

    Then you can paste the register content to current buffer with "ap

Using <C-R>= in insert mode is not good. It will write the output line by line, thus are very slow if your output has hundreds or thousands of the lines. The line indentation may also break if you use this method.

References#

Why can’t I search some Unicode characters?#

For example, given the following text:

if you place the cursor on the emoji and use ga, the output is:

<🆓> 127379, Hex 0001f193, Octal 370623 < ️> 65039, Hex fe0f, Octal 177017 < ️> 65039, Hex fe0f, Octal 177017

It shows that this character is actually made up of three Unicode characters! This is called variant form and the Unicode character U+FE0F is called a variant selector . There are other forms of multi-Unicode-char characters, for example, combining characters, where the character is made up of a base character and one or more decoration characters. In Vim, the main character is called base character and the other character that follows is called composing character.

If you use search the base character or the composing character using their Unicode code points, you will find disappointedly that no pattern are found.

It turns out the way we search the characters are wrong. To search the base character, you should follow it by \%C (in no-magic mode) or %C (in magic mode). For example, to search the above base character in the emoji, use

  • Magic mode: \v%U1f193%C
  • No-Magic Mode: \%U1f193\%C

To search the composing character, it is more complicated. You should type /<Ctrl-V>ufe0f:

  • <Ctrl-v>u: start Unicode input
  • fe0f: the code point of the composing character

Then press Enter to search.

References#

How do I clear the message on the status line?#

If you set the option laststatus to 2, after searching a word using *, you will find that the text is not cleared automatically. To clear the text , you can press Ctrl+L .

References#

How do I use a variable when calling shell command inside Neovim?#

You can use :execute, which will evaluate the expression followed before executing it. Suppose that you have defined a download URL variable URL, in order to download it using wget inside Neovim, you can use the following command:

Note the space inside '!wget ' because we use . to concatenate the arguments behind execute to form an expression. Without the space, the command you are going to run is !wget{the_content_of_URL}, which is apparently wrong.

References#

How to remove the trailing newline when using the system() function?#

When I wanted to assign the output of an external shell command to a Vim variable using system() function, I found that a trailing newline character was present in the returned string, which breaks a lot of things. For example,

let python_path = system('which python')

the variable python_path will contain an annoying newline. To remove this newline character, you can use various methods:

  • substitute(): you can replace the trailing newline with an empty string to remove it:

    substitute(python_path, '\n$', '', 'g')
  • string indexing: you can also utilize string indexing (see :h expr-[:]) if you are sure that there is only one newline at the end of the string:

    " remove last byte from the string
    let new_path=python_path[:-2]

References#