Posts Tagged 'vim'

Fix performance of VIM syntax highlighting in XML files

Normally Vim is damn fast and this is one reason why I love it. But today I got an XML file with over 3 million lines and after opening that file I wanted to jump to the end of the file. This took me over 1 minute which is unacceptable. Turning of syntax highlighting fixes this performance issue, but of course I don’t want to disable it.

I found the solution on stack overflow:

The problem was caused by one regex entry of syntax/xml.vim.
The line containing the regex for xmlSyncDT was causing this issue.

" synchronizing
" TODO !!! to be improved !!!

syn sync match xmlSyncDT grouphere  xmlDocType +\_.\(<!DOCTYPE\)\@=+

By commenting this out the performance issue is gone without noticeable sideeffects. The comment above the line shows already that the developer of this file is not happy with it. I can live perfectly without this.
Now I can jump to the end of the 3 million line file without any noticeable delays.

The post on Stackoverflow shows also how to debug such issues:

:syntime on
// do something
:syntime report

This statistic shows you where in the syntax highlighter the CPU time gets “burned”.

Another Update of my #Vim wombat256 colorscheme

Just updated my #Vim config and wombat256 colorscheme to show a nice
color column area with a decent non-distracting background color.

This is how it looks like (click to enlarge):


Wombat256 for #Vim has now an own Git Repo

I just moved my wombat256 colorscheme for console #Vim to a separate Git repository.
This makes it easier for you guys to use it simply by using pathogen & Co.
I also updated my Vim repo to make use of this separate repo.

Checkout it out on

Vim Section Navigation

Normally #Vim uses easy to remember mnemonics like d2w (delete two words).
But when it comes to section navigation using ‘[[‘, ‘]]’, ‘[]’, and ‘][‘ it looks weired.
At least if you expect, that the opening and closing brackets are somehow matching opening
and closing braces.

(In C like languages function scopes {…} are sections so you can easily jump
to the next or previous function.)

I tried to figure out the system behind so that this is easy to remember for me.
Most of the time you want to jump to the start of function, so to a ‘{‘.
Vim tries to make typing easy, and because pressing a key twice is easier than pressing two different keys,
Vim uses ‘[[‘ to jump to the previous ‘{‘ and ‘]]’ for jumping to the next ‘{‘.
The first bracket gives the direction. By repeating the key you say “jump to an opening brace”.

For the case that you want to jump to a closing ‘}’ just use the other key. The first direction key stays the same.
So ‘[]’ jumps to the previous ‘}’ and ‘][‘ goes to the next ‘}’.


  • The direction is obvious and easy to remember
  • Jump to a opening brace: repeat key
  • Jump to a closing brace: use the other key

If you are new to Vim, please check out also ‘{‘, ‘}’, ‘(‘, ‘)’, ‘%’, w, b for navigation.
Every Vim user should know these keys.
Use “:help <key>” to get help for it.

Updated Wombat256 Colorscheme

After working a while with the Solarized colorscheme I came back to my wombat256 colorscheme, which is based on the original wombat for gvim from Lars H. Nielsen.
Yesterday I improved it a little bit to fix some issues that I didn’t like:

  • Fix background color of NonText
  • Add new hilight groups for the ShowMarks plugin to make the signs column look nice and consistent with the rest of the theme.

You find it here:

This is how it looks like (click to enlarge):

YCM FixIt Feature

YouCompleteMe (YCM) is really an awsome plugin. But today this blog post is not about completion support, it’s about YCM’s FixIt feature. If you are developer and have seen already compiler errors like this:

expected ';' at end of declaration

then I’m sure you also thought already: “If the compiler knows already the solution for the problem, why it can’t fix it automatically?” Well, at least you might think so when using an IDE like Visual Studio.

As a Vim user it is more obvious that compiler and editor are two separate things and the compiler can’t fix it. But Vim with YCM can do exactly that. The command :YcmCompleter FixIt does exactly what we want. YCM shows the capability of doing so by adding the text (FixIt) to the error message. If you map this command to a keyboard shortcut like the following you can fix those issues with a single keypress:

" Apply YCM FixIt
map <F9> :YcmCompleter FixIt<CR>

Here is a short video to demonstrate the feature (click on the GIF to show in full size): ycm_syntax

New Keystroke GUI with Vim support

I’ve created an updated version of my Keystroke-gui keylogger,
which can be controlled by Vim Hooks.
Keystroke is keylogger and visualizer which can be used for screencasts.
This is especially useful when recording screencasts for Vim, because in Vim’s normal mode you cannot see what is typed, opposed to insert mode. But in normal made most of the “magic” happens 😉
The new version of Keystroke can be controlled over a TCP socket. Actually it
supports the following commands:

  • disable: disable the logger (actually just the visualization)
  • enable: enable the logger again
  • insertEnter: enter Vim’s insert mode
  • insertLeave: leave Vim’s insert mode

This TCP server is used by Vim to tell the Keystroke when vim is started, exited, and when it enters/leaves insertMode. Some helper BASH script which simply do a “echo ‘command’ | nc localhost 9999′ are use to form the client side of the communication. Vim’s autocmd feature is used to execute those scrips.

augroup logger
    autocmd VimEnter * :call system('$HOME/vim/enable_logger')
    autocmd VimLeave * :call system('$HOME/vim/disable_logger')
    autocmd InsertEnter * :call system('$HOME/vim/insert_enter')
    autocmd InsertLeave * :call system('$HOME/vim/insert_leave')
augroup end

When Keystroke is set to insertMode it only displays control keys like
<C-x><C-l> <tab>, or <enter>. Because the normal keys you see anyway in the buffer.

Of course keystroke is also useful for other types of screencasts, it is not
limited to Vim. But the Vim support is unique afaik.

If you want to give it a try you can clone the git repo

This new feature is currently available only on the branch
FEATURE_MORE_CONFIG. I’ll need more testing before I release it, but it works

What would be this post without a short demo? So here it comes (click on the GIF to show in full size):


What is still missing: More config options to adapt to different situations.
E.g. what keys get filtered and what keys are shown.

Have fun 😉