2012-12-23

Apache restart with Vim autocmd

In order to execute a command right after saving a file in Vim, you can use the :autocmd command. Here is a quick example how it can be useful with Apache files.

NB: on my system, Debian in this case, an Apache file is automatically recognized as filetype=apache.

augroup apache
    autocmd BufWritePost */sites-enabled/* !/etc/init.d/apache2 restart
augroup END

2012-07-30

Vim and Vala

I once wrote a quick note about Vala and Vim (or Vim and Vala) and the use of the Tag List plugin. Here is a clean post about these two beasts.

Vim — probably the best editor out there, at least always after trying out different editors I end up with Vim — has great plugins. However there is a lack of support for the Vala language. So here are two basic add-ins to include in the Vim editor.

Vala syntax

First there is no syntax color for this language. A quick fix is to use the C# syntax with the command :set filetype=cs. That works but is not ideal, ideal is to install a vala.syntax file, and there is one available on this GNOME Live! page.

First download the file from this page and save it under ~/.vim/syntax/. Next add the following lines to your ~/.vimrc file:
" Filetypes
augroup filetypedetect
        au! BufRead,BufNewFile *.vala,*.vapi setfiletype vala
augroup END

augroup vala
        autocmd BufRead *.vala,*.vapi set tw=100 efm=%f:%1.%c-%[%^:]%#:\ %t%[%^:]%#:\ %m
augroup END

Tag List

Tag List is a powerful plugin that lets you explore classes or functions from a source file, also called a source code browser. The installation steps are simple, they are also available bellow, and again to get it working with Vala there is a small hack to include inside the ~/.vimrc file.

First download the latest version of taglist from this page. Then uncompress the archive with, for example, the command line:
unzip -x taglist_45.zip -d $HOME/.vim/
Then go inside ~/.vim/doc, run Vim and inside Vim execute the command :helptags .:
cd ~/.vim/doc
vim
:helptags .
Finally add the following lines inside ~/.vimrc:
" Work-around Tag List for Vala
let tlist_vala_settings='c#;d:macro;t:typedef;n:namespace;c:class;'.
  \ 'E:event;g:enum;s:struct;i:interface;'.
  \ 'p:properties;m:method'

Now Vim is ready for Vala, and it's possible to browse source code by typing the command :TlistToggle.

Screenshot of Vim Vala Tag List
Vim Vala Tag List

2012-01-22

.screenrc

So I pimped up my .screenrc, and since it's been a long time I didn't care about my hardstatus I keep the content here just in case I need it again in a few years...

defscrollback 2048
startup_message off
caption always "%{= Wk}%-w%{= KW}%f%n %t%{-}%+w"
hardstatus off
hardstatus alwayslastline
hardstatus string "%{= ky}[ %H %l ]%=%{= kg}%{+b}[ %n %t ]%-=%{= ky}[ %D %d.%m.%Y %0c ]"

screen -t irssi 0
screen -t mutt 1
screen -t bubbie 2