Wednesday 2 May 2012

Spell checker in Vim

Vim's built in spell checker seems a little easier than externally using aspell. Firstly activate the feature in Vim

:set spell

Choose your language (for example)

:set spelllang=en_gb

You can add words that are spelled incorrectly (goes in something like ~/vim/en.utf-8.add) by simply going to the word that is highlighted and using the key sequence

zg

to add the word. See

:help spell

for more information.

Friday 20 April 2012

dos2unix on Mac OSX

File conversion from dos to unix files on OSX has always been a bit flaky for me. Handily the tr command in one of two variants does the job:


tr '\r' '\n' < dosfile > unixfile


tr -d '\r' < dosfile > unixfile

Tuesday 27 March 2012

Padding for superscript and subscript axis labels in gnuplot

By default gnuplot doesn't align superscripts and subscripts:
T_c^{/Symbol \245}

But, that leaves an ugly space between the symbol and superscript. You can force alignment with an @ character:

T@_c^{/Symbol \245}
 This works fine for standard characters, but for slanted variables, the align character makes the superscript overlap. To fix this we insert a partial before the infty symbol in the superscript. To do this we combine two text effects, blank characters &{a} and font size scaling {/* }:

T@_c^{{/*0.5 &{c}}{/Symbol \245}}

To give the desired result. You can change the factor 0.5 to whatever you need, with 1.0 being full character width.

Tuesday 20 March 2012

Bash function to wget from user space in york

This can be placed in .bashrc and can be used to get a file from (your username abc500)

http://www-users.york.ac.uk/~abc500

(this is on unix0 in the web directory.

wgetyork ()
{
if [ -f "$1" ];then
rm "$1";
fi
wget http://www-users.york.ac.uk/~abc500/"$1"
}

it checks for the file because wget will save the file you download as filename.1 if you already have a file called filename. Call it using

wgetyork filename

Thursday 15 October 2009

cropping pdfs from terminal

From terminal you can use pdfcrop, which should be installed on most linux systems. As its terminal based it is easier to script.

example

pdfcrop --margins '5 0 5 10' --clip input.pdf output.pdf

Friday 4 September 2009

Make tar.gz

tar czvf myarchive.tar.gz myfile

Monday 15 June 2009

Multiple files in gnuplot

Seems obvious now but you can use paste

e.g.

plot "< paste file1.dat file2.dat" using 1:($2/$4) w points