Posts for: #Vim

fixing vim’s [[ and ]] for bad code

I just added something to my .vim/c.vim to make [[ and ]] work even if the code does not have { on new lines.

    function! FindFunctionDefinition(dir)
            let l:lastpattern = @/
            if a:dir==-1
                    ?^\(\a.*(\_[^\)]*) *\)\{,1\}{
            elseif a:dir==1
                    /^\(\a.*(\_[^\)]*) *\)\{,1\}{
            endif 
            let @/ = l:lastpattern
    endfunction

    nmap [[ :call FindFunctionDefinition(-1)<CR>
    nmap ]] :call FindFunctionDefinition(1)<CR>

This will make [[ and ]] find the next and previous function even if the first { is not in the first column.

Read more →

tags/cscope for system headers

I love tags files for in coding, and enjoy using the tag feature in [vim]{tag/vim} as well as the derived tag-based completion. I do a lot of my development in the kernel, so all I usually have to do is put /usr/src/linux into my vim tags configuration.

Sometimes I have to do some user space hacking too, and I often forget all the names of glib and pthread library functions. Having a system wide tags file is very very useful. Below is a Makefile that I carry around with me and place in /usr/include to keep my system tags in sync.

Read more →

vim7 from source

I found a bug in vim6.4 (my comment block was too big and the line after the comment block was not left-justified) and wanted to see if vim7 had a fix.

Read more →

bash vi editing mode

bash comand line

For a few years now I've been using vi editing mode for bash and anything that uses readline. Here is how I've set things up.

In .bashrc I use the following to enable vi editing mode:

        set -o vi
This allows me to type as usual and use ESC to get into vi command mode. Since ESC is so far away I frequently use control-[... unless I feel I need the exercise.

Read more →