tridactyl / tridactyl

A Vim-like interface for Firefox, inspired by Vimperator/Pentadactyl.
https://tridactyl.xyz
Other
5.21k stars 399 forks source link

Feature: Option to auto open external editor on input focus #1873

Open simonwjackson opened 5 years ago

simonwjackson commented 5 years ago

It would be nice to have the option to open vim automatically when the focus is placed on an text input field.

bovine3dom commented 5 years ago

This would be simple if we had FocusEnter / FocusLeave autocommands, so if anyone is interested in this I would suggest they attempted that first.

glacambre commented 5 years ago

These autocommands would need to provide a way to tell the difference between an input field and a textarea/codemirror/contenteditable/ace element - firenvim used to take over these elements indiscriminately and it was slightly annoying. Input fields usually don't deserve to be edited in a real editor.

simonwjackson commented 4 years ago

For those who stumble across this issue, I have found a solution that works well for my needs.

" Set terminal
set editorcmd kitty --class floatingAppFocus -- vim -c "set noshowmode | set noruler | set laststatus=0 | set noshowcmd | set cmdheight=1 |  nnoremap <ESC><ESC> :q!<ENTER> | nnoremap <ENTER> :x<ENTER> | inoremap <ENTER> <ESC>:x!<ENTER>" %f

bind --mode=normal gi composite focusinput -l | editor

This gets rid of most of vim's HUD and, and allows for quick entry be remapping the <ENTER> and <ESC> keys to (accept or cancel)

This works well for single line inputs, but if you often use multi-line <textarea />'s you should probably remove the <Enter> remappings (last two commands)