Tuesday, March 24, 2009

Vim auto completion

I responded to a comment on the Daily Vim about auto completion. I decided to post it here as well as the comment ended up being kind of long. The comment by Casey asks if there is a way to turn off omni auto completion for perl as it goes through the entire POD collection evey time. I provide several solutions. Read the original article for a quicj intro to auto completion in insert mode in Vim.

The original article points out that there is built in auto completion in Vim. All you have to do is use it is type Ctrl-x Ctrl-o in insert mode and vim will try to complete what you have started typing or pop up a list of all completions if the cursor is not immediately preceded by anything.

Original comment follows:

Try this command to change the auto completion to the simpler syntax highlighting hints as the auto completer.

:setlocal omnifunc=syntaxcomplete#Complete

If that is what you always want for Perl add this to your .vimrc after all your other auto commands.

autocmd Filetype perl setlocal omnifunc=syntaxcomplete#Complete

If you want syntax completion rather than omni completion for all file types use * for the file type. If you want to fail over to syntax completion for file types that don't have omni completion put this in your .vimrc after your other auto commands.

if has("autocmd") && exists("+omnifunc")
autocmd Filetype *
\ if &omnifunc == "" |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif
endif

You can also do something a little more complex which just disable the perlPOD part of the perl filetype omni complete.

Try this command:

let g:omni_syntax_group_exclude_perl = 'perlPOD'

generically it's:

let g:omni_syntax_group_exclude_{filetype} = 'comma,separated,list'

And you can get the complete list of syntax groups while in a file with the filetype in question with this command:

:syntax list

Then just add that command to your .vimrc to make it permanent.

Check out this help topic for more info:

:h ft-syntax-omni

*Updated

And for the complete low down on the idiosyncrasies of each filetype check out:

:h compl-omni-filetypes

And here's another tip I picked up Ctrl-o : in insert mode will allow you to run a command and then return to insert mode. Neatly avoiding the Esc : ... i or a syndrome.

*Updated again

FYI Pressing Ctrl-o in insert mode puts you in normal mode for one command. You are not limited to using : to get to the ex command line. You can use p to put or y to yank etc.

*Further updates

For those times when you just want to save keystrokes or avoid typos:

Ctrl-P completes from previous words in document
Ctrl-N completes from following words in document
Ctrl-X Ctrl-F completes file names
0 Ctrl-D removes all indent for the current line

Tuesday, March 3, 2009

I think bio-engineering and habitat engineering are smarter

I posted this in the comments section of a science post about the current thinking that the only solution to climate change is climate engineering. I think that is a back idea. Not just because it encourages the fantasy of terraforming other planets and wild irrational space travel. But also because it's a wrong headed idea based on a premise that we don't have the technology to survive and thrive in any environment. It is only in our best interests to do so. My TEDTalks.com fueled diatribe follows.

Geo-engineering is a bad idea and a waste of resources that should be going to bio-engineering and habitat engineering research, development, and manufacturing. The threats to our existence on our planet are much farther ranging than climate change. Climate change is a natural process. Ice ages are where the glaciers that created the great lakes and that have recently melted away in places came from. We've got a swing by the gravitational force of the black hole at the center of our galaxy through direct alignment with our Sun. Which should be an interesting demonstration of just how powerful the magnetic and gravitational field of a black hole at that distance is when focused through the gravitational field as powerful as our Suns. We've got the possiblities of several disasters that are happen on a cyclical basis around that same time. The two super volcanoes. One right here in or I should say that is Yellowstone Park. The occasional reversal, polarity flipping, and 1000 year disappearances of the earths magnetic field that coincidently keeps the Sun from burning off our atmosphere. There is also the Atlantic shelf that should wipe the Americas clear of anything not bedrock if it shifts significantly. And that is not even mentioning the many unmonitored solar objects which could really ruin our day or the fact that the moon is slowly floating away and will have a massive effect on our climate.

My point is that if we are planning to survive beyond our infancy. Yes I say infancy because it is infantile to chase after the idea of money as a life goal. And yes I say idea because that is all money or any possession is. I say let us come up with a plan that lays out exactly what kind of technology we would need to survive all of these events. No, not survive, but thrive in the face of all of these events and more. The "rich" are holding back the future because they incorrectly be!ieve it is unprofitable to them to have everyone off the grid and living free. If you could satisfy all of your energy needs from the Sun via locally and communally generated windpower, water power, sea power, thermoelectric, magnetosphere, solar collector, or what have you. And you dealt with others as equals. Everyone being responsible for themselves and the world as a whole without arbitrary governance by ignorance encouraged by profiteers. And you were educated about the realities of our ability to harness even the simplest of technologies to solve all of our problems like drought, famine, hunger, transportation, shelter, communication, and survival. You would no longer be a consumer. In fact for the cost of a car (~$20,000) you could buy all the equipment needed to setup a microfactory and be a manufacturer. Check out http://www.fabathome.com/ and http://www.ted.com/index.php/talks/neil_gershenfeld_on_fab_labs.html Or check out the virtues of collaboration over institutions http://www.ted.com/index.php/talks/clay_shirky_on_institutions_versus_co... And check out 6 ways mushroms can save the world http://www.ted.com/index.php/talks/paul_stamets_on_6_ways_mushrooms_can_... Or open source architecture http://www.ted.com/index.php/talks/cameron_sinclair_on_open_source_archi... We need to collaborate on using the technology that is already available to build the technology needed to thrive during extreme adversity. We must evolve beyond the womb of the Earth. To do so we don't need to travel to other planets and terraform them to match our requirements. What we need is to evolve by raising the bar and saying we aren't dependent on a very fragile environment to survive. We have the technology we need the will.