Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

modify Ctrl-G in Vim

Tags:

vim

config

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

like image 524
posop Avatar asked Oct 20 '25 15:10

posop


2 Answers

Try

:nnoremap <c-g> 1<c-g>
like image 64
steffen Avatar answered Oct 22 '25 05:10

steffen


What about

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

which avoids a recursion?

like image 25
Jens Avatar answered Oct 22 '25 06:10

Jens