Archiv der Kategorie: Uncategorized

Creating vim split window with arbitrary content

What: Create a split window in Vim with arbitrary content
Why: Displaying information easily along text your are editing
How: Use Vimscript

A simple Vimscript script

Create a file test.vim with the following content. It defines a function which creates a new buffer, adds text to it and show it in a split window on the right.

function! test#test()
  let buffernum = bufadd("")
  call bufload(buffernum)
  call setbufline(buffernum, 1, "Hey ho")
  execute "vertical rightbelow sb " . buffernum
endfunc

Use the defined function

There are multiple ways, the function can be used. You can create a plugin (see https://learnvimscriptthehardway.stevelosh.com/chapters/41.html) or call the function from within Vim:

1
2
:source test.vim
:call test#test()

Convert raw images to jpeg

What: Convert raw camera images (like in CR2 format) to jpeg
Why: Smaller image size and easier handling in other programms
How: Use dcraw and pnmtojpeg in Debian

Installation of tools

1
2
sudo apt-get install dcraw
sudo apt-get install pnmtopng

Small script to iterate over the raw image directory

1
2
3
4
for fn in /home/frank/images/*.CR2; do
    target="${fn/.CR2/.jpeg}"
    dcraw -c "$fn" | pnmtojpeg > "$target"
done