Vim setup

Again, this is mostly a social bookmark to have a trace of what different parts of my configuration files in my Vim folder do. Feel free to steal whatever part you like. Note that not all of these settings will work without additional plugins. The ones I use on daily basis are: Powerline, bclose, voom and latex-suite.

A hint: Since I am using several computers I use Dropbox to synchronize all of my vim configurations thus my .vim folder on every machine is just a symlink to the Dropbox folder. I have moved my vimrc file there as well and source it from the original .vimrc file in the home folder.

" In case we are in a 256 color capable terminal
set t_Co=256

" Set a right colorscheme colorscheme zenburn

" Let Powerline use nice symbols let g:Powerline_symbols = 'fancy'

" Look for modelines embedded in source files, this is especially useful when " getting python code from other developers set modeline

" The only GUI element we want is the icon, remove menubar, toolbars etc. set go=i

" Always show the statusline set laststatus=2

" Display the beginning of the last line at the end of the buffer set display=lastline

" Turn on the syntax highlighting syntax on

" Set default window size to something sensible set lines=60 set columns=170 " " Set the editor to wrap long lines on words set wrap set linebreak

" Do not insert break lines to long lines set textwidth=0 set wrapmargin=0

" Turn on folding set foldenable

" Make folding indent sensitive set foldmethod=indent

" Don't autofold anything (but I can still fold manually) set foldlevel=100

" don't open folds when you search into them set foldopen-=search

" don't open folds when you undo stuff set foldopen-=undo

" Start the filetype plugin, this is really necessary filetype plugin on

"set fuopt=maxvert

" I use simple php templates au BufNewFile,BufRead *.tmpl setf php

" Load doxygen syntax highlighting when necessary let g:load_doxygen_syntax=1

" Add doxygen syntax highlighting to all cpp files au BufNewFile,BufRead *.cpp setf cpp.doxygen

" Add jQuery syntax highlighting au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery

" Activate line numbers set number

" Tab size to 4 spaces, and no expanding of tabs to spaces! set tabstop=4 set shiftwidth=4 set noexpandtab

" Display only 5 first suggestions when correcting orthograph set spellsuggest=best,5

" I use the <,> shortcut to align a paragraph to the wrap width nmap , gqap " " Use Ctrl-W+to close current file without closing the split (needs bclose &#34; plugin) nmap &lt;C-W&gt; <Plug>Kwbd

" Enable the use of Ctrl-Space and Ctrl-Enter for completion imap <C-S-space> <C-n> imap <C-space> <C-p> imap <C-CR> <C-x><C-o>

" Map the up/down arrow keys to follow visual lines, not the real ones map <Up> gk map <Down> gj imap <Down> <C-o>gj imap <Up> <C-o>gk

" Map Meta-j and Meta-k to follow visual lines map <M-j> gj map <M-k> gk

" Map Home and End to go to beginning and end of the visual line map <End> g<End> map <Home> g<Home> imap <End> <C-o>g<End> imap <Home> <C-o>g<Home>

" Make Meta-Shift-MouseScroll create a visual block selection noremap <M-S-LeftMouse> <4-LeftMouse> inoremap <M-S-LeftMouse> <4-LeftMouse> noremap <M-S-LeftDrag> <LeftDrag> inoremap <M-S-LeftDrag> <LeftDrag>

"set statusline=%<[%02n]\ %F%(\ %m%h%w%y%r%)\ %a%=\ %8l,%c%V/%L\ (%P) " Map gw to switch the word under the cursors with the next one nnoremap <silent> gw "_yiw:s/(\%#\w+)(\W+)(\w+)/\3\2\1/<CR><c-o><c-l>

" Map gl to switch the word under the cursor with the previous one nnoremap <silent> gl "_yiw?\w+_W+\%#<CR>:s/(\%#\w+)(_W+)(\w+)/\3\2\1/<CR><c-o><c-l>

" Map F3 to show the list of buffers map <F3> :buffers<CR>:b<space>

" Map F4 to switch between .h and .cpp file map <F4> :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp,<CR>g`"

" Map F5 and F6 to go to next/previous error marker map <F5> :cp<CR> map <F6> :cn<CR>

" Map F8 to save all files and run Make map <F8> :wall<CR>:make<CR>

" Start indenting scheme automatically filetype plugin indent on

" Use the right grep command on mac set grepprg=grep\ -nH\ $*

" Of course we are using latex let g:tex_flavor='latex'

" Autogenerate ctags on C/C++ source file save "au BufWritePost .c,.cpp,*.h silent! !ctags -R &

" If we are on a Mac if has("unix") && match(system("uname"),'Darwin') != -1 let g:platform_MAC=1 " Setup a nice font for powerline set guifont=Meslo\ LG\ M\ DZ\ for\ Powerline:h12

" Receive option keys as meta set macmeta

" Map :TB for mode for writing text on a big screen command TB colorscheme mayansmoke|set spell|set linespace=8|set guifont=Meslo\ LG\ M\ DZ\ for\ Powerline:h20|set fu " Map :TB for mode for writing text on a small screen command T colorscheme mayansmoke|set spell|set linespace=8|set guifont=Meslo\ LG\ M\ DZ\ for\ Powerline:h14 " Map :TB for mode for writing code command C colorscheme zenburn|set nospell|set linespace=0|set guifont=Meslo\ LG\ M\ DZ\ for\ Powerline:h12

" If we are on Linux else set guifont=Droid\ Sans\ Mono\ for\ Powerline\ 12 let g:Powerline_symbols = 'fancy'

" Map Meta+V as paste from system clipboard imap <M-v> <Esc>"+pa imap <M-S-v> <Esc>"+Pa nmap <M-v> "+p nmap <M-S-v> "+P

" Map Meta+C as copy to system clipboard vmap <M-c> "+y

" Map Ctrl+S as save nmap <C-s> :w<CR> imap <C-s> <Esc>:w<CR>a

" Map :TB for mode for writing text command T colorscheme mayansmoke|set spell|set linespace=8|set guifont=Droid\ Sans\ Mono\ for\ Powerline\ 14 " Map :TB for mode for writing code command C colorscheme zenburn|set nospell|set linespace=0|set guifont=Droid\ Sans\ Mono\ for\ Powerline\ 10 endif

" Deletes double lines and such from a SVN log function! CleanSVNLog() %s/^-$//g %s/^r\d\d.$//g %s/\n\n\n/\r\r/ endfunction

US Extended layout for Mac with switched `/~ and §/± keys

The Mac keyboard layout is weird. Some choices Apple made when designing it are good but some of them really come from outer space. Why would anybody need a ± symbol on his keyboard is beyond me. Luckily Ukelele software provides an acceptable solution.

Personally I use U.S. Extended layout for almost everything. The only time I switch is when I have a very lengthy french text to write. (Speaking of which, why does french layout have a  character directly on the keyboard? Just how often would anybody use that?). So, in order to keep the layout consistent with other keyboards I have made a U.S. Extended+ version which changes flips the §± and `~ keys around.

Download it here:

USExtended+

How to make Uncle Ben's chili sauce not suck

1

When Leader Price discontinued my preferred chili sauce I was angry and very sad. Oddly enough, Intermarché did the same and removed chili from their selection of Claude Léger sauces. Obviously there is no market for chili in France. What is done is done and we, cheap chili lovers, are now stuck with the Uncle Ben’s crap.

But let us not fall into despair, there is a way to save this non-perishable canned (bottled?) food franchise. The recipe is extremely simple, take a bottle of Uncle Ben’s chili sauce, add in a can of tomato paste and an appropriate amount of Sriracha sauce. And, voilà, ready to cook and serve. Preferably with bacon and rice.

List of useful links to hack your OS X installation

This is more of a social bookmark than a full article. OS X is pretty neat but the ever-present philosophy of “our way of doing it is the right way” can be frustrating from time to time. Since I do not really like the trend of paraphrasing already written articles I will just dump a bunch of links here and say what I used them for.

Fix Home and End keys behaviour

Home and End keys should go to the beginning and end of the line you are on while editing. In OS X they scroll to the top and the bottom of the current document, which is retarded.

A ton of useful hidden settings

I like keyboard repeat. Also I like to be able to copy text from QuickLook.

Use QuickLook from the terminal

I use this for my side-project of making Midnight Commander actually usable on OS X. So far I did not have time to really invest into it.

Duck gizzard salad, the Yoz-way

Since the last recipe was for a burger, let us make something healthier. Like a salad. However let us make it tasty as well, like by adding a pint of fat.

Ingredients

  1. Mesclun
  2. Duck gizzards
  3. Tomatoes
  4. Västerbottensost (Swedish cheese)
  5. Cashew nuts
  6. Salt
  7. Pepper

Preparation of ingredients

Wash the salad, dice the tomatoes (wash them first, eh). Dice the cheese.

If your duck needs to be heated in bain-marie do so. Cut the meat to smaller pieces (keep the fat).

Cooking

Heat a frying pan. Use the fat from the duck to grease it. Throw the duck and cashew nuts in. Salt, pepper and stir for a bit.

Take a salad bowl and throw everything in. Mix vigorously.

Afterword

Making salad is easy. Just take anything you have in the fridge and throw it into a bowl. The more colors the better.

duck-salad

The almighty Yozburger

Hunger strikes again! And best remedy for hunger is food! And best food is… burgers!

Ingredients

Possibilities are endless but decisions have to be made. Usually I put this into a burger, but feel free to add whatever you like.

  1. Hamburger bun (big one)
  2. Beef burger
  3. Bacon
  4. Cheddar cheese
  5. Egg
  6. Tomato
  7. Onion
  8. Lettuce (or Chinese cabbage)
  9. Salt
  10. Pepper
  11. Brown sugar
  12. Pork fat

Preparation of ingredients

Slice the onion to stripes. Slice tomatoes to circular slices. Cut the lettuce to smaller leaves.

Cooking

Start of by melting the fat on a pan. Put the bacon in and pour brown sugar over it to make candied bacon.

yozburger

Remove the bacon, salt and pepper the burger and put it on the pan (use the same pan for everything). When the steak is almost done (rare) put the onions and tomato and lettuce in. Also start frying the egg (and salt it a bit). It is important to cook the onions, lettuce and tomato in the same oil as the bacon and the burger. If you do not have enough place to put everything into the pan then cook what you must after you have removed the burger.

Start assembling the burger. From bottom I usually do : bun, cheese, onions, tomato, burger, cheese, onions, tomato, lettuce, egg, bun. Refer to the diagram for more precise information.

Secret knack : after I finish assembling the burger, just before putting the egg in I pour all of the oil from the pan into the burger. This serves as the best sauce you will ever have and this way you will avoid using unhealthy sauces like ketchup or mayo.

Final word

No words are necessary, just look at the beauty!

yozburger-photo

Best editor for Chinese text on Mac

I have spent some time (like an hour or so) looking for a good editor for Chinese script on Mac OS X. To my surprise most of what I have tried sucked in one or more ways.

Competitors

Of course, I have started with the editor I use to edit plaintext daily - iA Writer. For once, I have said to myself, the humongous font this editor uses would be very useful. Sadly, iA Writer uses the default OS X font for chinese. This derivate of Heiti is quite broken and many glyphs are wrong (this was pointed out to me by a native speaker). Also, line height of lines with chinese characters is weird, and it changes depending of the presence of non-chinese characters in it (including blank space). I have reported the issue to the authors and it was acknowledged so there might be a different font used in future versions… we will see.

So my first choice did not work out. No worries, there are plenty other editors to check. My second choice was MacVim, which is the best invention since sliced bread. The experience was very poor. The insert mode works well, as expected, however the normal mode hates IMKQIM input method. It would seem that Vim was not meant to be used with other than standard input methods, which is understandable.

Moving on. Since alternative software did not work out I tried the native solutions. TextEdit is usually a very good text editor, if you do not need any features. When writing immediately (in plain text mode), you will run into the same problem as with iA Writer : horrible font. You can change the font for plain text mode, of course, but you have to choose the right one. STSong is a good choice, with other fonts you might run into problems with line heights (as some fonts miss some glyphs). Fraise suffers from similar problems.

I have also tried Pages, it works really well, with the right fonts. Line heights are always OK. But it is not a plain text editor, and it has all the downsides of a text processor with hundreds of options.

Conclusion

Finally, I ended up with yet another editor. I have dug up the rusty FocusWriter which I have abandoned previously to iA Writer. The possibility to switch themes makes it a good choice for different scripts. My choice was the 华文细黑 font. Best of all FocusWriter is available on all platforms, so I just use that on Linux as well.


Edit 2015-10-18

iA Writer no longer has the aforementioned problems, at least in OSX 10.11

Cannot be unseen

On my trip to London I have stumbled upon a bridge with a curious design of the cable holding contraption.

Once seen, this cannot be unseen. Well, at least it gives an interesting picture. Would be probably better in worse weather though.

cannot-be-unseen

Carbonara Supercharge

When you are dying of hunger you need to swallow something with a lot of calories of all sorts (just in case), and you need to do it fast. This is a ten minute recipe for delicious pasta with enough fat to give you a minor heart-attack.

Today we are cooking a spinoff of spaghetti (or whatever, all pasta tastes the same) carbonara.

Ingredients

ingredients

You should always have these around in your house anyways, but maybe you will have to add 10 minutes for shopping

  1. Pasta (I use spaghetti or penne)
  2. Sliced bacon
  3. Liquid cream (or any other, actually)
  4. Parmesan cheese
  5. Emmental cheese
  6. Canned sliced mushrooms
  7. Egg
  8. Onion
  9. Bonus: White Wine

Preparation of ingredients

Nada. Well, open the can of mushrooms at least. Oh, and dice the onion.

Cooking

Depending on your pasta you will have to start cooking it at some random moment during the cooking of the sauce. Or you can just cook it after sauce is ready, it can wait, the pasta can not.

Start by frying the onions in a pan. Once they are ready put in the bacon. Cook until the bacon changes colour and add sliced mushrooms. Cook for like a minute and then add some cream. Afterwards add some cheese (either or both), not too much, and cook until it disolves. If you are rich enough add a spoonful or two of white wine into the mix now. Repeat the previous step until you think you have enough cheese in the mix. Cook for a bit. Now put in the egg and stirr furiously.

Voilà! Dinner is ready.

finished

Fix the home and end keys in Firefox with Keyconfig and Vimperator

Somme funny man thought that it would be good to screw up the behavior of home and end keys in firefox on Mac. Nobody knows why and everybody is complaining. Also, the same genius have made the ⌘→ and ⌘← commands navigate in history instead of doing what they do in every other application which is “move to the end or beginning of the line”.

Oh well.. Luckily there IS a solution for this. The extension keyconfig will fix half of the problem. Get the keyconfing extension here and disable the incriminating keys. Many thanks to the author. Now you have working command keys. As for the home and end key, I fixed my problem in vimperator, since it is an extension I use on all of my firefoxes. Basically the idea is to remap home and end (along with +shift variants)) so they fire off the command+arrow commands. Here is the code, enjoy :

imap <Home> <M-Left>
imap <End> <M-Right>
imap <S-End> <M-S-Right>
imap <S-Home> <M-S-Left>

Either run it in the vimperator command line and do a :mkvimperatorrc! or put it directly into your configuration file.