Is it possible to have VIM auto populate a file based on the extension?
For example, when I open a new .sh
file, I would like VIM to automatically type
#!/bin/bash
as the first line. (This example simplified down to the essentials)
to enter the *edit* mode and type any JavaScript keyword in the text editor and press *Ctrl + x* followed by *Ctrl + o*. Vim editor will show the possible auto-complete suggestions.
To initiate code completion enter insert mode and type Ctrl-X Ctrl-U . By default Vim will open a popup if there is more than one completion. When using omnifunc you will use Ctrl-X Ctrl-O to start code completion.
The auto-completion system (Intellisense) in VSCode is arguably its best feature. Lucky for us, it's been ported over to Vim!
Omni completion provides smart autocompletion for programs. When invoked, the text before the cursor is inspected to guess what might follow. A popup menu offers word completion choices that may include struct and class members, system functions, and more.
Check the section on "skeleton" in the vim help section:
:help skeleton
For your case, you should add a line like the following to your .vimrc:
autocmd BufNewFile *.sh 0r ~/vim/skeleton.sh
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With