Fandom

Vim Tips Wiki

Inserting a prefix in a parameter list

Redirected from VimTip387

1,624pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Tip 387 Printable Monobook Previous Next

created 2002 · complexity Intermediate · author feral · version 6.0


This is a way to quickly prefix a character (or characters) to a parameter list, via :substitute

In the thought that others may like the same preferred style as I, here is an easy way to prefix each param with an underscore.

The command:

:s/\<\(\I\i*\s\{-}[,)]\)/_\1/g

A sample menu entry:

amenu Fe&ral's.Prefix\ underscores\ to\ params <Esc><Esc>:s/\<\(\I\i*\s\{-}[,)]\)/_\1/g <Bar> :noh<CR>

An ExampleEdit

Before:

BOOL CSomeView::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)

After:

BOOL CSomeView::Create(DWORD _dwStyle, const RECT& _rect, CWnd* _pParentWnd, UINT _nID)

ReferencesEdit

CommentsEdit

Also on Fandom

Random Wiki