NewFiveFour | Blog | Portfolio


Unix: Change the keyboard layout using a key switch

If you want to type using another keyboard quickly you can use setxkbmap to change your X windows keyboard using a keymap.

Let’s say you want to switch from a us keyboard to a french keyboard. Use setxkbmap us,fr -option grp:ralt_shift_toggle

Then press right alt and shift together to switch between the two. I hold shift then tap alt gr

unix

Vim: rebind escape and caps lock on the command line

If you are using vim a lot, and touch type, you may find reaching up to press escape all the time ruins your typing.

You can rebind escape to caps lock, and vice versa, throughout all your X apps using xmodmap.

Use this in ~/.Xmodmap

clear Lock
keycode 9 = Caps_Lock
keycode 0x42 = Escape

And then use the command, probably in your ~/.bashrc, xmodmap ~/.Xmodmap to do the rebind.

vim unix

Vim: command line mode

First set -o vi and you can press escape (or whatever you’d bound that to) to use the vim commands on the current commanded typed in on the command line.

You can also press v and it will open up vim and you can edit the command in the full vim editor.

You made need to put EDITOR=vim in your .bashrc file.

vim unix

Use html to order a border with a title around things

You can group items with a border in HTML using fieldset and you can also give that border a title using legend.

The title breaks the border briefly at the top.

Here’s an example which you can use to impress your friends, family, dogs, cats and potential parliamentary representatives.

<fieldset style="border: 1px dashed black">
  <legend>Ladies and gentlemen we are floating in space</legend>
  Sup
</fieldset>
css html

HTML, CSS: Make a div float in the middle of page

First make the position of the div fixed. We’ll place it at the bottom of our screen by setting the bottom to 5px.

We make it so the div starts from the middle of the screen by setting the left property to 50%.

But this won’t make it exactly in the middle of the screen, of course, since this mean it starts from the middle of the screen, not that its centre point is in the middle of the screen.

To properly centre the div use the transform property to move the div half its width to the left.

  <div
    style="position: fixed; bottom: 5px; left: 50%; transform: translateX(-50%);">
    I am centered. Rejoice.
  </div>
css html

Page 1 of 78
Next