vimrc updates

This commit is contained in:
waldek 2021-08-30 22:58:42 +02:00
parent f78ee71434
commit dd88ef6d8d
2 changed files with 59 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

View File

@ -240,4 +240,63 @@ This is a setting you can either fix in your vimrc, or change in the fly, your c
**Don't be greedy and set it to the root of your hard drive. **Don't be greedy and set it to the root of your hard drive.
This will slow vim down way too much because there are just too many files and folders!** This will slow vim down way too much because there are just too many files and folders!**
## IDE like features without plugins
We already have syntax highlighting via the `set syntax=on` feature but we can also have autocomplete for quite a lot of scripting languages out of the box.
This is one of the main reasons we install vim-nox and not vim!
The shortcut to achieve it is a double whammy `<c-x><c-o>` which triggers omnicomplete.
Have a look at `:help omnifunc` to learn more about it but first, a hands on example.
1. Open the python file we made before with `vim -u ~/vimrc_basic ~/python_test.py`
2. Navigate to the end of the file, go into **insert** mode and type `datetime.`
3. Remain in insert mode after the `.` and hit `<c-x><c-o>`
4. Stay calm and read on.
![autocomplete](./assets/vim_02.png)
The screenshot above is probably very much like what you're confronted with.
The *dropdown* menu is a context aware autocomplete menu meaning these are all functions, methods, classes or variables belonging to this module.
The horizontal split window at the top shows the documentation of the menu item you have selected.
You can navigate this list either with the *arrows* or with `<c-n>` to go down and `<c-p>` to go up.
I personally don't like the documentation jumping up and down on my screen so you can add the following to remove it all together.
Now to be able to view the documentation we'll need to install some plugins.
I have not found a clean way of hiding the preview window *and* adding a shortcut to show documentation.
```
set completeopt-=preview
```
### Complete more things
Vim can do a lot more than just complete python code.
When you press `<c-x>` you'll see a menu at the bottom along these lines.
```
-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)
```
Every `^CHARACTER` is a different mode of autocomplete!
Try out the `^K` one just for fun.
It will probably say this the following.
```
'dictionary' option is empty
```
We can *set* a dictionary, which is just a list of words, to autocomplete from.
Let me walk you through an example.
1. Open up a blank text file with my basic vimrc.
2. Go into **insert** mode and type in `hipp`.
3. Stay in **insert** mode and type `<c-x><c-k>` which will show the same error message as before.
4. Exit insert mode with `ESC`
5. Set the dictionary by typing `:set dictionary=/usr/share/dict/american-english` (you should have this file)
6. Go into **insert** moder after `hipp` and type `<c-x><c-k>` again.
Nice no?
## Beyond vanilla vim
TODO