You searched for articles tagged with Vim.

[ #134 ] Manually Setting Vim Syntax Permalink

Perl, Vim Added less than a year ago

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



[ #113 ] Merging Changes using VimDiff Permalink

Vim Added a year and a bit ago

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.




[ #110 ] Vim - What Changes Did I Make? Permalink

Vim Added a year and a bit ago

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:

diffchanges.vim

DiffWithSaved function




[ #108 ] Perly Vim Permalink

Vim, Perl Added a year and a bit ago and last edited a year and a bit ago

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.




[ #91 ] Case Insensitive Vim Search Permalink

Vim Added a year and a bit ago

There are a couple of options. If you want to do a once-off case-insensitive search, include the sequence \c in your search string anywhere, for example:

/SoMeThInG\c

... will match Something, something, someThing etc.

If you want case-insensitive searching to be the default, then add this to your .vimrc:

:set ic

If you are using set ic you might want to use the smart-case setting:

:set scs

... which, when the two settings are combined, will be mean that when you search for an all-lowercase word it will match any case, but if you have at least one uppercase character in the search string it will be case-sensitive. For example:

/mouse

... will match Mouse, MOUSE, mouse etc, but:

/Mouse

... will only match Mouse.




[ #89 ] .vimrc file Permalink

Vim Added a year and a bit ago

Here is my .vimrc file, for coding goodness!

set hidden
set nocompatible
set bs=2
set ts=4
set sw=4
syntax on
set softtabstop=4
set expandtab
set nohlsearch
set ruler
set ai
set backupdir=~/.backup
set directory=~/.backup

This config gives syntax highlighting and 4-space "tabs." It also puts all the swap files in the ~/.backup dir so they don't pollute your workspace. If you are having problems with the arrow-keys making weird codes (like "B" and "D") then using this config will fix that.

First remember to:

$ mkdir ~/.backup



[ #12 ] Vim-Fu Permalink

Vim Added nearly two years ago and last edited a year and a bit ago

Some random Vim tips:

Visually select a block v
Change a visually selected block c
Lowercase a visually selected block u
Uppercase a visually selected block U

Add another file to the end of this one G:read file

Go to line 58 :58
Go to top of file gg
Go to bottom of file G
Go to top of screen H
Go to middle of screen M
Go to bottom of screen L

Go to start of line 0 (zero)
Go to end of line $

Go back to the previously edited line '.
Go back to where you were before you jumped ''
Undo u
Redo :redo

Change a word cw
Change the rest of the line c$

Visually select a column of text ^v (control and v)

Write (save) :w
Write and quit :wq

Open multiple files in split screen view:

$ vim -o file1 file2 file3

Switch to the lower split ^w DOWN (control and w, then down arrow)
Switch to the upper split screen ^w UP (control and w, then up arrow)
Open a new file in a split window :sp file

Open the filename under the cursor gf Go to the next occurrence of the term under the cursor * Go to the definition of the variable under the cursor gd Go to the global definition of the variable under the cursor gD

List buffers :ls




(Nothing Older) ... Newer Posts

Colophon

Django Python 960.gs Git Vim NetBSD Nginx

The Author

This is the blog of Brad Willis, a software engineer living in Brisbane.

Meta

Help
Latest entries

*BSD Agile Apache Apple apt Athletics Best-Practice Censorship Comedy Cool Crosswords Deployment Django English Exim Firefox Git Hardcore Health irssi Javascript Jira Languages Linux Makefile Mathematics Mobile Broadband Mutt MySQL NetBSD nginx Nokia OpenVZ OSX Perl Privacy Python Rant Requirements rsync Ruby Shell Slackware SQL SQLite SSH Standards Subversion Television Testing ThisBlog Vim VMWare (Fusion) VPN X zsh

Recent Entries

Checking for exceptions in doctests
Homer's Curling Speech
retry in Python
Vim Makefile tabs
Centos (or RH) IPTables
Converting ssh2 public keys to openssh
Vim comment hints
Context managers in Perl
Dish rotation
Git - fixing commit user
apt stuff
Using shell variables in AWK
Linux - Too many open files
Tell gvim to save and quit... remotely
Vim - automatically remove whitespace at EOL
Python - relative paths from within modules
TV Aspect Ratios
Git - Which commits are in your branch only?
Subversion setup cheat sheet
Force detach a screen session
Modify sudo's use of environment variables
Install all Perl modules
Mutt - delete old messages
OpenVZ VPS and swap space
fail2ban on NetBSD for ssh
NetBSD - Using sup
Python - testing for a sys.exit
Python Best Practice Link Dump
Python script names
Perl - Using an expensive module
Speed of git clone
Perl Modules with Custom Prefix
Perl: tr vs. s
Brilliant sysadmin Reference
Why is GRUB better than LILO?
Why is swap space important?
Perldoc Output
Git's Index
Jira Project Keys
Git GUI

Links

ChoppingBoard, DaveMisc, Project365, RageQuit