Blog
Vim commands for the daily life
My favorite editor is vim but until recently i didn't really use its great features (well even yet i may only use about 5% of its capabilities). So i decided to read a bit through the documentation and there is lot of interesting stuff, and so i am going to write a short summary about the commands which i use in daily life (not the cryptic ones which were designed to attract perl programmers ;)) However this is not ment as an introduction for newbies or a documentation type :help or checkout vimtutor for these things. Ok here it goes:
args # show opened files
args file3 fil4 # set new ones
next next! wnext # go to the next/previous file
prev prev! wprev # in the list depending on what you
# want to do with your changes.
split [filename] # split window horizontally /
vsplit [filename] # vertically
CTRL + W W # switch between the windows
CTRL + W [UP/DOWN-KEY]
CTRL + W _ # maximize current window
:qall # close all windows
:only # close all windows expect the current one
"{a-z}y # yank a line into a register
"{a-z}p # past the content from a register
:mark {a-z} # set a mark store it in a register
:m{a-z}
:'{a-z} # jump to a given mark
q{a-z} # record some commands and store
# them in a register type q to stop
@{a-z} # recording and @{a-z} to playOh and here is an excellent VIM Reference Card for those of you who like to further investigate in this topic.
APT keeps packages back
Ever wondered why apt keeps some packages back when doing an apt-get update && apt-get upgrade?
apt-get upgrade
Reading package lists... Done
Building dependency tree... Done
The following packages have been kept back:
cpp gcc libcurl3 ssh tasksel x-window-system-core xbase-clients xlibmesa-gl
xutils
0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.The message actually means that there is a new package version available but for some reason it can not be installed. Maybe the package has broken or new dependencies. If you want further information about a specific packages this can be done by setting a special options like shown below.
apt-get -s -o Debug::pkgProblemResolver=yes install xutils > /dev/null
Starting
Starting 2
Package xutils has broken dep on xbase-clients
Considering xbase-clients 4 as a solution to xutils 10013
Added xbase-clients to the remove list
Fixing xutils via remove of xbase-clients
Package x-window-system-core has broken dep on xbase-clients
Considering xbase-clients 4 as a solution to x-window-system-core 0
Re-Instated libglu1-xorg
Re-Instated libdmx1
Re-Instated libxkbfile1
Re-Instated libxkbui1
Re-Instated libxss1
Re-Instated libxxf86dga1
Re-Instated libxxf86misc1
Re-Instated libxxf86vm1
Re-Instated xbase-clients
Re-Instated x-window-system-core
Package xlibmesa-glu has broken dep on libglu1
Considering libglu1-xorg 0 as a solution to xlibmesa-glu 15
Added libglu1-xorg to the remove list
Considering libglu1-mesa 0 as a solution to xlibmesa-glu 15
Fixing xlibmesa-glu via keep of libglu1-xorg
Package x-window-system-core has broken dep on libglu1-xorg
Considering libglu1-xorg 0 as a solution to x-window-system-core 0
Holding Back x-window-system-core rather than change libglu1-xorg
DoneSo you can see the problem, usually an apt-get install [packagename] should solve it. However if you have numerous packages which have been kept back you may want to do an apt-get dist-upgrade. For further information check out the APT-Howto.
Displaying recursive datastructures with Smarty
For those of you who don't know what smarty is, it is a PHP Templating-Engine whose main idea is to separate programm logic from presentation.
I would suggest reading the excellent documentation for a brief overview.
A quite common task in web development is to display recursive data structures such as tree menus etc. However this can be a bit tricky for someone new to smarty. There is currently no built in mechanism for doing so, but with the possibility to include subfiles it can be done. Here is how it works.
menu.tpl
{* other html stuff *}
<h2>Linklist by category</h2>
{include file="menu-recursive.tpl" menu=$menu depth=1}
</div>
{* other html stuff *}menu-recursive.tpl
{foreach name=entry item=entry from=$menu.entries}
{if $smarty.foreach.entry.first}
<ul>
{/if}
<li>{$entry}</a></li>
{if $smarty.foreach.entry.last}
{if $menu.sub}
{include file="menu-recursive.tpl" menu=$menu.sub depth=$depth+1}
{/if}
</ul>
{/if}
{foreachelse}
<p>This category contains currently no entries.</p>
{/foreach}PHP-file with the datastructure.
$demo = array(
'entries' => array('demo 1','demo 2'),
'sub' => array(
'entries' => array('demo 1.1','demo 2.1'),
'sub' => array(
'entries' => array('demo 1.1.1','demo 2.1.1')
)
)
);
$smarty->assign('menu',$demo);
$smarty->display('menu.tpl');You should get a list looking similar to the one below.
- demo 1
- demo 2
- demo 1.1
- demo 2.1
- demo 1.1.1
- demo 2.1.1
However if a designer is able to understand this stuff is a completly different story...
Fluxbox key bindings after switchover to Xorg
I finally had some time to switch my desktop box over to Xorg. However after the successful upgrade i noticed that my fluxbox key bindings were no longer working. After a while i found out that the ugly Windows-Key, which i am using as a modifier , did no longer work as expected. xmodmap confirmed that:
xmodmap: up to 2 keys per modifier, (keycodes in parentheses):
shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x25), Control_R (0x6d)
mod1 Alt_L (0x40)
mod2 Num_Lock (0x4d)
mod3 Mode_switch (0x71)
mod4
mod5 Scroll_Lock (0x4e)
So first of all i had to look up the keycode of the windows key. This can be done with xev:
KeyRelease event, serial 25, synthetic NO, window 0x1200001,
root 0x4b, subw 0x1200002, time 3292297, (45,38), root:(108,116),
state 0x0, keycode 115 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes: ""
Now that we know the keycode we can define our modifier:
xmodmap -e 'keycode 115 = Super_L'
xmodmap -e 'add Mod4 = Super_L'Now xmodmap should print something like this
xmodmap: up to 2 keys per modifier, (keycodes in parentheses):
shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock (0x42)
control Control_L (0x25), Control_R (0x6d)
mod1 Alt_L (0x40)
mod2 Num_Lock (0x4d)
mod3 Mode_switch (0x71)
mod4 Super_L (0x73)
mod5 Scroll_Lock (0x4e)And the modifiers should once again work properly. You can add the two xmodmap commands to your ~/.xsession file, this will adjust the settings on every start of the xserver.
cat >> ~/.xsession << "EOF"
xmodmap -e 'keycode 115 = Super_L'
xmodmap -e 'add Mod4 = Super_L'
EOFMail handling with getmail, procmail, mutt and exim4
I recently needed to reinstall my mailing tools and so i am going to write about it in this blogentry. I have used getmail to fetch the mails from the POP3 Server, procmail to filter them, mutt to display them and finally exim4 to forward new mails to my providers server for delivering.
