posop
posop

Reputation: 531

modify Ctrl-G in Vim

I am looking to modify Ctrl-G <C-g> in the following way:

Current Behavior: <C-g>

"test.txt" 89 lines --1%--

What I want is to modify so it's output looks like 1 Ctrl-G 1<C-g>

"~/Documents/test.txt" 89 lines --1%--

if I make the following mapping:

map <C-g> echo expand('%:p')

I get:

/home/me/Documents/test.txt

I would like to push <C-g> and get:

"~/Documents/test.txt" 89 lines --1%--

Can you help me fix my mapping to get desired output?

I am piggy-backing heavily off this question: Display name of the current file in vim? by muthuh

Upvotes: 4

Views: 605

Answers (2)

steffen
steffen

Reputation: 17028

Try

:nnoremap <c-g> 1<c-g>

Upvotes: 6

Jens
Jens

Reputation: 72707

What about

:noremap <C-g> 1<C-g>

which avoids a recursion?

Upvotes: 3

Related Questions