Defining commands in Vim
Suppose that you have created a function that replaces <k>Ctrl</k>
with <kbd>Ctrl</kbd>
(this is useful in protips to save some time ;)
function! ReplaceKbd()
" <kbd>Ctrl</kbd> => <kbd>Ctrl</kbd>
:%s/<kbd>/<kbd>/ge
:%s/<\/k>/<\/kbd>/ge
endfunction
In order to call that function you have to type :call ReplaceKbd()
, which can soon become boring. Let’s save some key strokes by defining a command:
command ReplaceKbd :call ReplaceKbd()
Now you only have to type: :ReplaceKbd()
. This is the same kind of a method like :GundoShow
, :Gwrite
and the like.
Written by Wojtek Ryrych
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Related Tags
#vim
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#