Archive for category: Vim

Use the Last Search Term for a Substitution in Vim

5 April, 2011 (17:38) | Vim, [English Posts] | By: Wolfgang

It is quite usual to first search for something in vim just to use it in a substitution afterwards. To do so just leave the substitution pattern of the substitution command empty. This way it is possible to build complex regular expressions interactively with the help of the search function and later use it ...

Deleting Lines not Containing Pattern in Vim

7 July, 2010 (06:30) | Vim, [English Posts] | By: Wolfgang

Suppose we are given a huge list of textual data with entries like this:

name:
email:
address:
country:

The only two lines for each entry needed for further processing are the ones with name and email in it.

To delete lines not containing one of these two entries in vim the :g! or :v command can be used:

:g!/\(^name\|^email\)/d
:v/\(^name\|^email\)/d

See help ...

Inserting Text in Vim’s Visual Blockmode

29 June, 2010 (06:30) | Vim, [English Posts] | By: Wolfgang

Vim's visual block mode is great for editing tabular text files. Change to visual block mode by using Ctrl-V. After that use the common Vim-move commands to select the block of text you want to edit. The next command will affect the whole block instead of only one character. To delete the whole block ...

Replacing Text on Every Other Line in Vim

21 June, 2010 (06:30) | Vim, [English Posts] | By: Wolfgang

One way to replace text directly within vim on every other line is to use the command

:g/^/ if line('.')%2|s/^/%/.

This only applies the substitution on line numbers that can be divided by two without rest. In the present case the beginnings of these lines (^) will be matched and there a percent sign (%) will ...

Inserting Specific Text Every Other Line in Vim

20 June, 2010 (06:30) | Vim, [English Posts] | By: Wolfgang

This is quite a specific problem but perhaps you run into a similar task one time. I have simplified the complex version of the real task to an easy and more generic version. Two files Titles.txt and Authors.txt are given, Papers.txt shows the desired result.

File "Titles.txt"

Paper 1 Title
Paper 2 Title
Paper 3 Title
Paper 4 Title

File ...

Vim and Zsh Tips

17 June, 2010 (06:30) | Vim, zsh, [English Posts] | By: Wolfgang

Today just a short link to a nice collection of useful Z-shell commands:
http://zzapper.co.uk/zshtips.html.

By the way, the authors Vim tips are great too: http://zzapper.co.uk/vimtips.html.

Ctrl-C and Ctrl-V in GVim

9 June, 2010 (06:30) | Linux, Mac OS X, Vim, [English Posts] | By: Wolfgang

If you are missing the default copy and paste shortcuts in GVim, map the keys accordingly and add this to your ~/.gvimrc:

nmap <C-V> "+gP
imap <C-V> <ESC><C-V>i
vmap <C-C> "+y

However this probably isn't the best idea because you are also overwriting default settings like Ctrl-V for the great visual mode.

If you are using OS X this ...

Spell Checking with Vim

23 May, 2010 (18:18) | Vim, [English Posts] | By: Wolfgang

Since Version 7.0 , released back in 2006, Vim has a built in spell checker. To enable it first set the desired spelling language by :set spelllang=en and then type :set spell to actually enable the spell checking feature. The spell checker is intelligent enough to ignore commands in you text, if you write ...

Umlaute in LaTeX-Dokumenten unter OS X

14 May, 2010 (00:45) | LaTeX, Mac OS X, Vim, [Deutschsprachige Einträge] | By: Wolfgang

Durch Verwendung einer der beiden nachfolgend angeführten Methoden sollten Probleme mit Umlauten am Mac endgültig der Vergangenheit angehören:

Kodierung ändern
Am schnellsten geht es, die Kodierung auf applemac zu setzen: \usepackage{inputenc}

Danach sollten Umlaute ganz normal angegeben werden können.

Ersetzen

Persönlich bevorzuge ich die seit jeher von LaTeX vorgesehene Variante Umlaute anzugeben: Dabei wird einfach \"a für ä, ...

Managing WordPress Blogentries with Vim

11 May, 2010 (21:47) | Vim, [English Posts] | By: Wolfgang

blogit.vim is a nice extension to write blog posts directly from within Vim. There are other scripts doing the same but only this one was updated recently. You can get it from its vim.org project page http://www.vim.org/scripts/script.php?script_id=2582 or the authors web site http://symlink.me/projects/blogit/wiki.To use the suggesteted formatting conversions let blogit_unformat='pandoc --from=html --to=rst --reference-links' and ...