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

推荐订阅源

S
SegmentFault 最新的问题
B
Blog
P
Proofpoint News Feed
美团技术团队
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
A
About on SuperTechFans
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Vercel News
Vercel News
有赞技术团队
有赞技术团队
小众软件
小众软件
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
H
Help Net Security
罗磊的独立博客
L
LangChain Blog
GbyAI
GbyAI
腾讯CDC
T
The Blog of Author Tim Ferriss
Microsoft Security Blog
Microsoft Security Blog

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 Techniques That Make My Life Easier -- Series 4
2019-09-17 · via jdhao's digital space

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

Check if a string contains a pattern?#

There are two simple ways:

  • Use match(str, pattern)
  • Use =~# or =~?

For match() function, Vim assumes that magic (see :h /magic) option is set for patterns. If pattern is found in str, it will return the index where the pattern starts. Otherwise, it will return -1.

You can also use regex match via =~# and =~? (see :h expr4). =~# matches cases during matching, while =~? ignores cases. During matching, it is always assumed that magic option is set.

References#

When should I capitalize the function names?#

For custom global functions, i.e., functions without the s: (see local-function), the function name must start with an uppercase letter. But for script local functions and auto-loaded functions (see :h autoload), you do not need to start the actual function name with uppercase letter.

References#

How to represent ALT key in mapping? M or A#

According to documentation (:h key-notation), <M-...> and <A-...> are the same. Both can be used to refer to Alt key.

How to check the actual key press that Nvim receives when I press a key?#

Sometimes, due to various reasons, when you press some key, what Nvim receives is not that key press. To check the key that Nvim actually receives, press Ctrl-V in insert mode and then press the key you want to check.

References#

How to repeat some character N times?#

If you are in normal mode, use <NUM>a<Chars><ESC> to input <NUM> repeated <Chars>.

References#

How do I execute a normal mode command in insert mode?#

Ctrl-O is used to leave insert mode, execute one normal mode command and go back to insert mode. For example, if you want to see your runtimepath value, you can first press ctrl-o and then use :echo &runtimepath to see the option’s value.

Wrap selection with quotes or other characters#

Install vim-surround. Go to visual block mode (press v in normal mode), select text you want to wrap, press S, and press the wrapping characters such ' or " or {.

If you want to indent the code and as well as wrap it, then you need to go to visual line mode (press V in normal mode)

References#

Rename multiple occurrences of a variable#

First, search the variable you want to rename. Then press cgn to change it. Go back to normal mode, press . (dot), the next match will be replaced with the new name. If you want to skip some match, press n.

It is not as powerful as the Sublime Text multiple cursor feature, but should suffice for refactoring your code most of the time.

Reference#

Search Unicode characters using its code point#

For example, if we would like to search a (Unicode code point is u+0041) in Neovim, the correct format is /\%u0041, see :h /character-classes for more info.

References#