Don't use Swedish keyboard with vim/screen/bash

Somebody told me they always use US keyboard for coding, and that it really makes a difference. I typically don't care too much about such, but when I started getting a slight pain in my wrists the other day, after many days of intense bash-/vim-/screening, I decided to make a try ... and my hands and wrists are forever grateful!

Finally it starts to make sense why somebody would choose a weird character such as " for switching between windows in screen! (something you do very repeateadly sometimes), but having it just one step to the right of the natural position of your right pinkie, makes more sense than the awful crippled left-hand grip to get [shift]-[2] on the swedish keyboard.

Coders in general will save some sanity by avoid the crippled right hand-grip with AltGr+[numkey] to get to [] and {}.

The rest is maybe a little more specific to heavy bash/vim/screen usage. I'll outline a few that I noticed below:

  • :, for the ubiquitous :w in vim (for saving( is very comfy placed under your right pinkie (with shift).
  • The $ sign is much comfier (for selecting to end of line in vim), avoiding another crippled AltGr-grip.
  • Same goes for the | sign (piping)
  • /, for searching in vim, is really nicely placed one step down and right from the right pinkie.
  • " is nicely placed just one step to the right of the pinkie-placement.
  • Even ~, even though requiring a slightly crippled left-hand grip even in US, at least prints out directly, as opposed to the required space to force it to print, in SE.

I'm sure there are many more, but these should be enough to make it worth to try it out a little if you're spending a lot of time in bash/vim/screen. In short: Only now I can see how anyone can really love working with these vim commands!

Only thing remaining is to find a nice place to map the åäö:s.

So far, I have added these two aliases to my ~/.bash_aliases, though, for quick switching between Swedish and US:

alias kbse='setxkbmap se'
alias kbus='setxkbmap us'

Where to change between Emacs and Vim mode for bash line editing?

[samuel ~]$ cat ~/.inputrc
set editing-mode emacs


Simple command line python "IDE" with ipython, screen and vim

I often need to develop python scripts on some remote server where I can't run graphical python IDEs like spyder.

I'm too lazy to set up an advanced vim config with full blown IDE-like features (except for some basic python support).

I have found that a much simpler solution is a GNU screen session with two vertically split screens, one for the main coding in vim, and a smalelr one below, for running ipython, to run and debug the script as it is written.

I found it useful enough to figure out how to start such a setup with one command. This is how to do it:

create a file ~/.screenrc.pydev and place the following in it:

resize 20
exec ipython
exec vim

then add this to the bottom of your ~/.bashrc or ~/.bash_aliases:

alias pydev='screen -mS PyDev -c ~/.screenrc.pydev'

... and source the file:

source ~/.bashrc

Now, you can start your command line python environment by:

cd some-folder-with-python-files

The result:

Oh, and to jump between the screen windows, do:

[Ctrl] + [A], [Tab]

Had to learn some basic vim

I just realized that git is using vim as text editor (hope it is possible to change to nano or equivalent). Anyway, as for now I guess I better just learn som basic vim commands. saved me.

The most important commands to remember are:

i - enter "insert mode"
a - enter "append mode"
ESC - leave "insert" or "append mode"
x - delete one character
dd - delete one line (and store it in clipboard)
ZZ - Save and close
ZQ - Close w/o saving