Love, caffeine and omlette

Tag: vim

Resize panes in VIM with your arrow-keys

It's worth to write about your learning's. Even if they seem small.

Recently I turned of my arrow keys in VIM and blogged about it.

After reading my article Philipp Fehre suggested, that I could take this a step further and use the arrow keys for resizing panes.

So I went ahead and copied the following 5 lines from his .vimrc:

" Make arrowkey do something usefull, resize the viewports accordingly
nnoremap <Left> :vertical resize +5<CR>
nnoremap <Right> :vertical resize -5<CR>
nnoremap <Up> :resize +5<CR>
nnoremap <Down> :resize -5<CR>

Phil was right! This is a great way of resizing panes.

Fighting bad habits with technology

I keep a list of stuff to improve. Whenever I catch something stupid it lands in there.

I try to get rid of these bad habits.

Often I find myself unable to solve the problem with willpower alone. Then I search for a solution that assists me. Maybe a little "barrier" or some kind of reminder. Let me show you, what I mean with this..

Looking at the keys all the time

When I started to program 5 years ago I looked onto my keyboard all the time. Sure - typing faster does not make you a better programmer - but typing with 2 fingers is not ergonomic.

I found a nice solution for my problem.

I bought a keyboard without letters. I was so bad to hit the proper keys, that nudged me towards learning it right. I have to admit though that I still have problems with some special keys 😉

Not moving enough during work

Like most people I had the problem that I did not take enough breaks. This was hard to change.

I started to work in Pomodoros (25 minutes of work and 5 minutes of break). Unfortunately I still did not leave my working space often enough.

So I took another iteration and added added a little AppleScript to my Pomodoro App..

After each Pomodoro my Pomodoro timer executes a little script that locks my Mac 😉

Surfing the web all the time

Unfortunately I am addicted to the internet. I am pretty OK with it most of the time — but not, when I want to be productive.

That's why i wrote a little script that blocks my internet access.

echo "Enough of this filthy internet" | cowsay -s
sudo route -n delete default &> /dev/null

If I need to be more specific with the site I need to block, I use a program called SelfControl.

This works great! Of course as a computer guy I could circumvent this — but I do not want to.

Force pushing to master

It happened frequently that I forced pushed to master. This was really annoying for me.

Image Source: Flickr / Pascal (CC BY 2.0)

My colleague Nikolay proposed to fix it with a script. That's just what I did.

I have not force pushed to master since. This script is now also in use at some of my colleagues.

Checking working email at home

I checked working email at home. I love my work to much to let my fingers from it - but I realize that I need time of it in order to rest.

Image Source: Flickr / Tama Leaver (CC BY 2.0)

There's a simple remedy for not reading work related emails at home: Delete the freaking email account on your computers at home. It's baffling how often you will look into your empty email-client thereafter..

Checking Twitter really often

There's so much chatter at Twitter. I checked Twitter hourly. Here's what I did:

  • Remove people that write to much
  • Add a URL block-filter
  • Delete Twitter from my iPhone

    This works really well for me.

Not using arrow keys in VIM

Another stupid habit of mine was, that I used the arrow keys in order to move in VIM.

This was pretty simple to fix: I disabled them!

 not use the arrow keys any more
 nnoremap <up>    <nop>
 nnoremap <down>  <nop>
 nnoremap <left>  <nop>
 nnoremap <right> <nop>
 inoremap <up>    <nop>
 inoremap <down>  <nop>
 inoremap <left>  <nop>
 inoremap <right> <nop>

It took only a week until I was not trying to hit them any more 😉

Being to digital

Another problem of me is, that I use all my electronic devices to much. Here is what I build to prevent this: Productivity Protector 2000.

It works.


What is my point to show you this little collection of personal hacks?

Do not be a victim of you're bad habits.

As Nerd we have superpowers: We analyze problems. We solve them. All day long. Start applying these skills to the rest of your life!

Save a file as root in vim

I often edit files without having the right permissions in VIM.

VIM can not safe a file

I changed the file and when VIM told me that I did not have the proper permissions to save it, I quit VIM and entered sudo !! to try it again.

This was of course stupid of me. Currently I try to be more mindful about this kind of problems and to fix them.

Here's the lines that I just added to my .vimrc

" Use :w!! to save as root!
cmap w!! w !sudo tee % >/dev/null

When I enter :w!! now VIM saves the file as root.

I hope I will not encounter this problem again.

How to not use the arrow keys any more in vim

I try to wrap my head around the VIM editor since a few months. Unfortunately I do not have enough discipline to use h-j-k-l as my movement keys. But there is a solution that will teach me..

I found it deep inside the .vimrc of my colleague Fabian.

nnoremap <up>    <nop>  
nnoremap <down>  <nop>  
nnoremap <left>  <nop>  
nnoremap <right> <nop>  
inoremap <up>    <nop>  
inoremap <down>  <nop>  
inoremap <left>  <nop>  
inoremap <right> <nop>  

This turns off the arrow keys. A really obvious way of doing it 😉

I will add this to my .vimrc right away!

Wish me luck!

© 2017

Theme by Anders NorenUp ↑