Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make VIM play typewriter sound when I write a letter?

After a lot of writing in Q10 on Windows, I got used to the typewriter sound it makes every time you press a key. At least for me it feels great to have this sort of sound feedback.

On Linux on the other hand, I love writing it VIM, because of it's editing features. How could I add this functionality to VIM?

Simply said, I want to play a sound every time I press a key in the insert mode.

like image 651
Jakub Arnold Avatar asked Dec 11 '10 18:12

Jakub Arnold


2 Answers

Alright, this kinda crazy, but it appears to work. First, grab yourself a typewriter sound in aiff format. Then put that typewriter sound in ~/.vim/support/my_typewriter_sound.aiff. Then add the following to your ~/.vimrc.

function! PlaySound()   silent! exec '!afplay ~/.vim/support/my_typewriter_sound.aiff &' endfunction autocmd CursorMovedI * call PlaySound() 

Note that the above function calls out to afplay, which I know works on a Mac and needs to be replaced with play on Linux. On Windows, I have no idea.

So you know what's happening above, we're first creating a function called PlaySound that shells out to afplay. We then setup an autocommand that gets fired anytime the cursor moves in insert mode. When it fires, it calls PlaySound.

like image 92
Trotter Avatar answered Sep 30 '22 10:09

Trotter


The plugin does exist. You can find it here: https://github.com/osyo-manga/vim-sound

However, you need to add sound effects files yourself, which you can find here: http://www.soundjay.com/typewriter-sounds.html

like image 27
kompowiec Avatar answered Sep 30 '22 11:09

kompowiec