Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Vim autocomplete a word based on words already found in the buffer?

Tags:

vim

How to make Vim autocomplete a word based on words already in the buffer?

How can I make Vim autocomplete words, based on words already found in the buffer, just like it is possible with Emacs (M-%)?

like image 774
Shuzheng Avatar asked Dec 17 '22 20:12

Shuzheng


1 Answers

<C-n> and <C-p> will complete what is in all buffers. <C-x><C-n> and <C-x><C-p> will do exactly what you asked for and only give completion for tokens in the current buffer. However, there are a lot of completion options in Vim. To learn more about them, I would suggest reading the help section on them :help ins-completion (this is called insert mode completion).

A few other completion options in Vim are <C-x><C-f> to complete file paths and <C-x><C-l> to complete entire lines.

like image 53
JakeD Avatar answered May 21 '23 07:05

JakeD