VIM 中的自动完成 快捷键

本文介绍VIM编辑器中的自动完成功能,包括单词、行、文件名、同义词及字典词的自动补全。通过使用Ctrl-X组合键,可以提高编程效率,例如快速重复现有行、自动填充已声明的函数定义等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这篇文章主要说明了VIM的以下几个自动操作:

  1. Word / pattern 自动完成
  2. 行自动完成
  3. Dictionary word completion
  4. File name completion
  5. Filling up words with similar meaning (Thesaurus word completion).


所遇这些操作斗鱼Ctrl-x 相关。

1. Using Ctrl-x Ctrl-n 实现word自动完成

  • CTRL-x CTRL-n : Word completion - forward
  • CTRL-x CTRL-p : Word completion - backward

2cdbbed761331eeda044df41.jpg

Fig: Keyword completion in Vi / Vim using Ctrl-x Ctrl-n

2. Ctrl-x Ctrl-l 实现行自动完成

100d8f6deeea3bcb42169442.jpg

Fig: Vim Whole line completion using Ctrl-x Ctrl-l


Typical usage for a programmers and administrators:

  • Repeat an existing line quickly in your file.
  • Automatically fill first line of the function definition, when the function is already declared elsewhere in the same file.

3. Ctrl-x Ctrl-f文件名自动完成

 

40c06f547f5c1b68d0090642.jpg

Fig: Vim File name completion using Ctrl-x Ctrl-f

 

4. Thesaurus Word Completion

Using this feature you can choose alternate words with the same meaning for the word that you’ve just typed. Our previous article explains about the thesaurus features for your Vim editor.

5. 用 Ctrl-x Ctrl-k自动完成字典

修改 ~/.vimrc添加词典.

$ cat ~/.vimrc
set dictionary+=/usr/share/dict/words
2562320a2bca350eb0351d42.jpg

 

Fig: Vim Dictionary word completion using Ctrl-x Ctrl-k

转载于:https://www.cnblogs.com/miniwiki/archive/2010/09/08/1821292.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值