plugins
register
You can list all previous copy-paste buffers quite easily :
| copy-paste register | |
|---|---|
It will display the last 20 buffer contents you use plus a buffer name like "2 or "z. You use that name to paste that buffer again:
| paste buffer | |
|---|---|
And there is your forgotten text again. You will be happy to see the register stays intact after closing the edited file.
todo list
This one seems to be simple enough :
Install with :
| vim todo lists | |
|---|---|
If you empty the .vimrc file you can use this command.
| ~/.vimrc | |
|---|---|
This shows that the function works. Actually you could set this as default because we usually are always editing
Note that you will get in trouble when enabling these lines :
The creation of new items will fail when hitting
I think this has to do with vundle, but we might get along fine without vundle ?
ctags for vim
The CTRL-5 (CTRL-]) option jumps to a tag under the cursor, and the dot '.' is not part of a keyword in the default setup. You steer this with the iskeyword setting , default is :
| ctags | |
|---|---|
Which is ok for c, but add this to ~/.vimrc for java development
| ctags | |
|---|---|
Now you can push CTRL-] anywhere on 'XMap.getDistance' and you will go to the correct member.
bad indentation
Especially when using the yaml indentation it goes horribly wrong. After a section like this, you might want to start a new object in the first column :
| indent | |
|---|---|
But yaml indentation decides it will be :
This will start to annoy the hell out of you, and what will annoy you more is the amount of non-working advise you get for disabling it. Finally i got it working by disabling this setting in ~/.vimrc : For the vundle plugins section, you had to disable these and this line re-enabled them again afterwards :
| restore indent | |
|---|---|
But this also seems to disable syntax coloring, because you should not read this as "set the plugin indent on" but as "set both plugin and indent on". This would be the equivalent :
So we only want to re-enable plugin :
| only re-enable plugin | |
|---|---|
per directory .vimrc
Main use : to have the correct makeprg in for instance java/Scons and makefile projects. Use this in the $HOME/.vimrc file :
I put it in the end so it overwrites the other settings. Now if you include a file called .vim.custom in the directory of choice with for instance :
| makeprg | |
|---|---|
That will be taken instead of the default scons.
tabs
I always use
| tabstop | |
|---|---|
To get a 4 space indentation in my programs. However, since using python it is not well mannered to use tabs as indentation, so to make these tabs 'soft-tabs' you can also add this to .vimrc :
| make space tabs | |
|---|---|
When you encounter older files still containing tabs you can search and replace them, or use :
| do the whole file | |
|---|---|
I ended up not using expandtab because you can't backup a complete tab with the backspace. I just use :retab some more when doing python.
vundle
Bundle for vim, you can easily install plugins in vim once this plugin is installed.
| install | |
|---|---|
This will put everything in the right place, now add this to your .vimrc :
It contains a plugin that is very handy for editing restructured text. And one commented out because i don't particularly found that very useful.
Riv knows RST format inside vim but the folding end general usage is not of much benefit. The second plugin however : instantrst is very useful and described in the next section.
If you open up vim with this .vimrc and type :
| install plugins | |
|---|---|
| clean plugins | |
|---|---|
Now you have a new plugin called InstantRst.
Instant rst
This plugin shows the result from you RST file inside your browser, usually at port :5676.
It opens up automatically if you enter the vim command below and you can see all editing while you type.
Troubleshooting
When command above does not work, there is not much info you get about it. But you can run the command standalone to see what the output is :
| instantRst | |
|---|---|
| error | |
|---|---|
It shows you what is wrong (python 3 not supported) and where to fix it. Edit the script and change the shebang in python2. If you run it again it will start with an empty browser window.
spelling
Automatic spelling control is an option in vim that can be very useful. Also i used to run spelling checks in sphinx-doc on a regular base, but this is a very time consuming task, especially looking up the problems and rerunning.
So direct checks are very useful:
How spelling check in vim works is that you set these values in your .vimrc (or better .vim.custom file in the top directory of your sphinx-doc project. The directory where you start vim from normally.
| spelling check | |
|---|---|
The bg=dark because of the highlighting that vim uses. Spellfile has to end in .add and will be created in the current directory alongside a binary version kees.add.spl . This file is probably a search index, so the main file can remain in the order created.
Now you can walk through all spelling errors with [s and ]s but beware you need to release the [ or ] key every time otherwise it just starts command 's' (change under cursor)
- [s : find previous spelling error
- ]s : find next spelling error
- zg: adds the word under the cursor to the .add file and index
- z=: prints a suggestion list to pick from
The errors are displayed with different colors :
Green background : spelling error, not found in dictionary or .add file Purple background : word is found bu should have a capital letter
The .add file will not be read by make spelling in sphinx-doc unless of course you add it to the source/spelling_wordlist.txt. Some experiments :
- setting spellfile=source/spelling_wordlist.lst does not work since it has to end in add
- setting spelling_word_list_filename='../kees.add' does work
- using spelling_wordlist.add does not work because of the underscore. It will complain with 'does not have a region name'
- Adding two lists together does work, and you will see that the index get's regenerated the first time you add a word (with zg) because all previously added errors will clear !
- If you just add two files it will contain double entries
- If you add a word again, it will just become multiple entries.
So based on that i would suggest this scheme for sphinx-doc projects :
- Alter the entry in sources/conf into spelling.add
- combine both files if needed by just concatenating
- regularly remove doubles with sort -uo sources/spelling.add sources/spelling.add
This last command will do it 'in-place', trying sort
Using this scheme does not take into account the per-file spelling list, try avoiding that or live with it.
ctrl-6 not working
This seems to be the default in newer installations. Ctrl-^ switches between files and not ctrl-6. But that means always pressing ctrl-shift-6 and that's horrible. Since ctrl-6 does nothing by default i just remap it in ~/.vimrc :
| ctrl-6 | |
|---|---|