Tuesday, 8 May 2012

Learning to make vim fast and lovable editor

.. Or settings and tips I have learnt to make vim nicer, but are not on by default. ( I will keep adding to this )

I am using vim as my main editor for a few years but since freelancing I am learning to use it even more.

Vimrc settings

My changes to vim at the moment look like this

syntax on
set bg=dark 
" indent
set cindent
set smartindent
set autoindent 
" tabs
set expandtab
set shiftwidth=2
set tabstop=4
set showmatch " Show matching brackets.
" auto complete + C-n
set showcmd " Show (partial) command in status line.
" case search
set ignorecase " search ingore case if all lower search
set smartcase " Do smart case matching (flips igonore if use any caps)
set incsearch " search as type
" highlight search
set hlsearch " highlight all searches " :nohlsearch
"set visualbell
"set cinkeys=0{,0},:,0#,!,!^F
set cinkeys=0{,0},:,0#
set cinwords=if,else,while,do,for,switch,case   " Which keywords should indent
imap <C-e> <esc>$a
imap <C-l> <esc>g_
:nmap <C-n> :tabnext<cr>
" Press Space to turn off highlighting and clear any message already displayed.
:nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
" Press F4 to toggle highlighting on/off, and show current value.
:noremap <F4> :set hlsearch! hlsearch?<CR>

Outside of the config you can open files in tabs inside vim and then tab between them
vim -p file1 file2 file3
then use 'tg' to go to the next tab

Open a grep search of files as tabs in vim
vim -p `fgrep -l cust_function core/*.php`
This would search for 'cust_function' in the dir core for php files

Vimdiff - visual character level diff from cmd line

vimdiff is much nicer to look at if you have to understand merging files on the cmd line.
if you migrate from

line by line without checking white space (so ignore tabs/spaces which can change with editors and versioning)
diff -w filea.php fileb.php
 files side by side if you need to see context of more than a couple of changes
diff -wy filea.php fileb.php
In this view you can scroll up and down but right edge gets cut, you can see marks in middle of page
| different
> change to right version
< change to left version

But those two show only lines. Vimdiff shows colours to show character changes and move around in a visual way
 vimdiff filea.php fileb.php
And if you add this to ~/.vimrc you dont see the white space changes which is nice.
set diffopt+=iwhite
When in vimdiff you can move between windows and also which is nice, push and pull changes between versions.
So move to change "dp" pushes change from left to right side. The other way "do" pulls it from right to left

To switch windows in vimdiff or to navigate windows in vimdiff or to change windows in vimdiff try the following: The ":vertical" command can be inserted before another command that splits a window. 
MOVING BETWEEN WINDOWS          
CTRL-W h        move to the window on the left         CTRL-W j        move to the window below
CTRL-W k        move to the window above 
CTRL-W l        move to the window on the right         CTRL-W t        move to the TOP window      
CTRL-W b        move to the BOTTOM window 
Moving windows  
CTRL-W K        move window to the upper 
CTRL-W H        move window to the far left
CTRL-W J        move window to the bottom         CTRL-W L        move window to the far right 

Have Vim jump to the last position when reopening a file
if has("autocmd")
  au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
      \| exe "normal! g'\"" | endif
endif

Auto complete comment block lines.
" In edit mode
" #b<return>
" type text
" #e<return>
:ab #b /************************************************
:ab #e ************************************************/
:ab #l /*----------------------------------------------*/

Show hidden characters, leading and tailing white space with
:set list
Then you can see if you have lots of white space as $ will be on end of lines
Next you can run a zap trailing white space
:1,$s/[ <tab>]*$//
and off with
:set nolist

source: http://www.oualline.com/vim-cook.html

Not quite vim but useful

You can get a sort of auto complete from your history file. So for example
cd PageUp
changes to
cd /file/path/i/used/earlier

or if your jumping around
cd /file/path/PageUpPageUp
becomes the last bit
cd /file/path/i/used/before/that

Change it here:
vim /etc/inputrc
Then uncomment the lines for using PageUp and PageDown to fill the rest of your cmd propt from your history
# alternate mappings for “page up” and “page down” to search the history
#”e[5~”: history-search-backward
#”e[6~”: history-search-forward

Friday, 27 April 2012

Freelance project work in Brighton or Remote from home

As we come into May 2012 I am looking for Freelance Web Development project work in Brighton or Remote from home from end May and June onwards.
Any sort of updating websites or maintaining them or building them new. I am a PHP web developer and also to project strategy and Social Media and SEO supported by Web Analytics.

So you could be anywhere in the world but I live in Brighton so will be talking to you from here or meeting you near by.

thanks

tristan

Thursday, 17 November 2011

This week I have mostly been looking for freelance work and django

This week I have mostly been getting my head into Python and learning django for my new blog/portfolio site. I want to find some more evening feelance work so time to get my pencil and code out on something for myself and get my self a new site so I can show some of the work I have been doing and see if I can get some more.

Things I have learnt about django so far that had caught me out:
It caches code to memory so use the test server and restart alot, this caught me out as sometimes files would update and sometimes not.
The django 4 stage tutorial is good and worth doing but I was trying to skip ahead and bring in other snippets for template creation and they were breaking because I had missed some small details on imports. So worth going slowly. The tutorial is nice as it does things basically and then goes back and layers over the last function with more features so you build up knowledge.

Thursday, 15 September 2011

Still here

Not so happy with the new minimal Blogger so am learning more Python and django so will be seeking to have some hacking weekends next month and get something new up and make more effort to post a bit. I find twitter so easy to brain dump, share and blog in that its hard to take the time to write more.

1. get fit
2. get a django site up
3. post more blogs

Sunday, 21 June 2009

Podcast take away lessons now included in Spanish course

Get extra value from your Spanish evening course from Cactus Language courses UK.
The Spanish courses in the UK and USA now have 10 hour lessons added to the 10week course. So you can take your teacher with you for extra training and extra help with your home study. You'll learn faster and can listen again at your own pace.

This is extra to your course so extra value from one of the UK's leading and most popular courses in London and 25 schools accoss the UK.

Come see them today.
Http://www.cactuslanguagetraining.com/en/languageminis

Tuesday, 10 March 2009

Are 1milliontweets worth the $1 they cost

I hope it becomes clearer as the idea grows and the promotion for this new cause to use Twitter gains steam.

@1milliontweets is an account for a charity that is asking for $1 to tweet through their account. They hope to reach 1 million tweets and their by write a book and raise some money for their causes. The Twestival for water charity was really well supported and I feel went with the theme of twitter for social gathering. This seems to cache in on the million dollar homepage that got a lots of publicity.

For a charity fair enough, but for twitter in this way I am not sure how good it is on a new account. When I wrote this had 173 followers, so the value to people sending messages at the moment is around that mark, where as after a few hundred thousand messages $1 will go a lot further for a company. Also with twitter being as it is you could just @1milliontweets or #1milliontweets in your message and it will be almost as effective.

Anyway we can watch and wait for how this works for them.

Thursday, 13 November 2008

Launching a new language learning site

We have just started to beta our new site. Learn about learning Spanish or start learning French as well as Italian, German and English. We will be adding more languages to the site soon.

The site is for people to share what learning a new language was like and us to share ways of learning and where is good to do it. So visit www.cactuslanguagetraining.com/en/ today.