Tuesday, 22 December 2009
Number Each Line of Current File
to merely display numbers
:set number
following will actually insert numbers but relies on external Linux utility nl
:new | r!nl # (where hash is alternate file name)
Vim Way
:%s/^/\=line('.'). ' '
Labels: numbering lines
Monday, 21 December 2009
Replace a line with the contents of a file
Replace a marker line (contaning just the word mark) with the contents of an
external file doc.txt
" replace string with contents of a file, -d deletes the "mark"
:g/^MARK$/r doc.txt | -d
Thursday, 10 December 2009
Integrating Vim and Cygwin
I use and love Cygwin but mostly use the standard Windows gVim (Gui Vim) rather than that supplied by Cygwin.
in my .vimrc I have
if has('win32')
source $VIMRUNTIME/mswin.vim
behave mswin
set shell=c:\\cygwin\\bin\\zsh.exe shellcmdflag=-c shellxquote=\"
else
set ff=unix
endif
You will probably prefer bash.exe rather than zsh.exe
I can then run zsh/bash scripts from the command line e.g.
:!grep blah blah
in my .vimrc I have
if has('win32')
source $VIMRUNTIME/mswin.vim
behave mswin
set shell=c:\\cygwin\\bin\\zsh.exe shellcmdflag=-c shellxquote=\"
else
set ff=unix
endif
You will probably prefer bash.exe rather than zsh.exe
I can then run zsh/bash scripts from the command line e.g.
:!grep blah blah
Labels: cygwin
Wednesday, 9 December 2009
How to Get the Latest Patched Version of VIM
The Cream project maintains the latest version of VIM you can download it here . On the download page you can get latest version of VIM with or without Cream.
Cream is a free, easy-to-use configuration of the famous Vim text editor for Microsoft Windows, GNU/Linux, and FreeBSD. It uses common menus, standard keyboard shortcuts, and has extensive editing functions for the beginner and expert alike.
The current version for win32 is gvim-7-2-303.exe they call this a one-click install
Cream is a free, easy-to-use configuration of the famous Vim text editor for Microsoft Windows, GNU/Linux, and FreeBSD. It uses common menus, standard keyboard shortcuts, and has extensive editing functions for the beginner and expert alike.
The current version for win32 is gvim-7-2-303.exe they call this a one-click install
Monday, 7 December 2009
The Power of Control R
The Control-R mechanism is very useful:-
:h i_CTRL-R
Usually used for inserting the contents of a register 0-9a-z
but can also insert the following special registers etc
'"' the unnamed register, containing the text of the last delete or
yank
'%' the current file name
'#' the alternate file name
'*' the clipboard contents (X11: primary selection)
'+' the clipboard contents
'/' the last search pattern
':' the last command-line
'.' the last inserted text
'-' the last small (less than a line) delete
=5*5 insert 25 into text (mini-calculator)
Subscribe to Posts [Atom]