I have set up this mapping:
nnoremap <silent> <F9> :%! perltidy -q -pbp<CR>
... now I just hit F9 and I'm set.
Add this to your ~/.vimrc file:
if has("gui_running")
imap <c-s> <Esc><c-s>
map <silent> <C-S> :if expand("%") == ""<CR>:browse confirm w<CR>:else<CR>:confirm w<CR>:endif<CR>
endif
It's easy - on the current tab that you want in a different spot, just execute:
:tabm num
... where num is the zero-indexed position you want to move it to.
When using vim an interesting idea is to save a session file for each ticket you are working on.
Say you are working on TICKET-881, and you have the 8 files relevant to this ticket open in tabs, you firstly save your session:
:mksession TICKET-881.vim
Then when you need to go back to work on that ticket at a later stage, start up with that session like so:
$ gvim -S TICKET-881.vim
... and all your tabs, environment, cursor positions etc will be like you left them. This can help to reduce the pain of context-switching between tickets and trying to remember exactly what files you were editing at the time.
Make sure your .perltidyrc is setup, then just:
:%!perltidy -q
... and voilĂ - tidy source.
Sometimes the syntax highlighter in vim gets confused with complicated syntax - and colours might go wrong for a string or comment etc.
You can force vim to refresh the syntax highlighting by pressing Ctrl-l (that's the letter L) - just like how you quickly clear the screen in terminals.
If you are editing a Perl script but the script name doesn't have a .pl extension and no hashbang line, your syntax highlighting will not work.
To manually set the syntax highlighting do this:
:set syntax=perl
Core Dump has a nice entry on this.
$ vimdiff file1 file2
Keyboard Shortcuts: do - Get changes from other window into the current window. dp - Put the changes from current window into the other window. ]c - Jump to the next change. [c - Jump to the previous change.
If you open a file in Vim, make some changes, then want to check those changes compared to when you opened it (do a diff before saving), then you have a few options:
:w !diff % -
... is an easy one. Others include:
Vim regexes aren't great, especially if you are used to Perl ones. When you are looking for a Perly way to substitute some text in Vim, try the simple:
:perldo s/something \d+/another/
This is a good way to make sure your ranges, special chars, character classes and flags etc work the way you have come to expect from using Perl.
By default this operation works on the entire file, but you can prefix the command with line ranges like you would with a normal Vim substitution.
Django Python 960.gs Git Vim NetBSD Nginx
The author is a software engineer living in Australia. He sux at guitar, loves camping, doesn't like cake, does like coffee and is a lazy home brewer.
Help
Latest entries
*BSD Agile Apache Apple Athletics Beer Best-Practice Censorship Comedy Cool Crosswords Deployment Django English Exim Firefox Git Hardcore Health Interface irssi Javascript Jira Languages Linux Makefile Markdown Mathematics Mobile Broadband MySQL NetBSD nginx Nokia OSX Perl Photo Privacy Python Rant Requirements rsync Ruby Shell Slackware SQL SQLite SSH Standards Subversion Testing ThisBlog Vim VMWare (Fusion) VPN WDTEM X Yum zsh
Yum
Possum
Git's Index
Jira Project Keys
The Coffee Shop
Git GUI
It is more important...
Questioning Unix (and Other) File Times
The Frog King Photo
Rain Cloud Photo
rsync
Timezone
utf8 in your Perl
Theatre Ceiling Photo
Some problems are so complex...
Colours in your PAGER
zsh vared
zsh magic-equals and double-star
Funny Tweets
iMac 27" i7
ChoppingBoard, Project365, RageQuit