Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to figure out some vimrc settings

Tags:

vim

I came across the following lines in a vimrc file and can't figure out what they're supposed to do or how they're supposed to work. Am thrown off by the use of the $ sign. Does it have any special meaning or is it used in a regular manner like any other character?

" Parenthesis/bracket expanding
vnoremap $1 <esc>`>a)<esc>`<i(<esc>
vnoremap $2 <esc>`>a]<esc>`<i[<esc>
vnoremap $3 <esc>`>a}<esc>`<i{<esc>
vnoremap $$ <esc>`>a"<esc>`<i"<esc>
vnoremap $q <esc>`>a'<esc>`<i'<esc>
vnoremap $e <esc>`>a"<esc>`<i"<esc>

" Map auto complete of (, ", ', [
inoremap $1 ()<esc>i
inoremap $2 []<esc>i
inoremap $3 {}<esc>i
inoremap $4 {<esc>o}<esc>O
inoremap $q ''<esc>i
inoremap $e ""<esc>i
inoremap $t <><esc>i

If anyone's interested. This is the link to the vimrc

like image 288
kshenoy Avatar asked Mar 10 '12 07:03

kshenoy


1 Answers

Looking at just two of these.

The first is a visual-mode mapping:

" Parenthesis/bracket expanding
vnoremap $1 <esc>`>a)<esc>`<i(<esc>

This wraps the selection in () when you type $1. First it jumps to the end of the selection ('>) and appends a ) before jumping to the beginning of the selection ('<) and inserting a (.

This is an insert-mode mapping:

" Map auto complete of (, ", ', [
inoremap $1 ()<esc>i

This inserts () when you type $1 and leaves the cursor in between the two parentheses.

like image 154
Johnsyweb Avatar answered Oct 23 '22 15:10

Johnsyweb