timeout and timeoutlen apply to mappings, such as netrw's gh.
These are pretty straightforward: if you increase the length of timeoutlen, then Vim will wait for longer after each keystroke of the mapping before aborting it and carrying out the behaviour of the keys typed so far. If you instead unset timeout, then Vim will wait forever for you to either type the complete mapping or type something which doesn't match any of your mappings.
ttimeout and ttimeoutlen apply to key codes.
A common example of something sends key codes is the arrow keys. In the terminal presses of the arrow keys are generally represented by sequences of characters. You can see what (Vim thinks) your terminal is sending when you press e.g. the left arrow key by executing the command:
:set <left>?
In my terminal, when I run the above, Vim outputs the following:
t_kl <Left> ^[O*D
This means that what my terminal sends to Vim when I press the arrow key is the sequences of characters: EscapeO*D.
(^[ is a plain-text representation of the ESC character)
The only way that Vim can distinguish these sequences from actual keypresses is the speed with which it receives them, and you configure this with the ttimeout and ttimeoutlen settings.
Thus, if you set ttimeoutlen to a sufficiently large value (try 5000: five seconds) then you can move your cursor to the left by literally typing EscapeO*D on your keyboard.
However, this also means that if you press Escape in visual mode, then Vim will wait 5 seconds to whether you actually pressed Escape (to exit visual mode) or in fact just pressed Left in an extremely slow terminal.
Generally, you want to set timeout and timeoutlen according to how quickly you generally type mappings, and you should set ttimeoutlen to a pretty small value: defaults.vim sets this to 100 milliseconds, but you can probably go a fair bit shorter than this without unwanted consequences.
Longer values of ttimeoutlen are only required for "slow terminals or very busy systems" when key codes are timing out, but as processor and network speeds increase this is less and less of an issue in practice.
timeoutis about mappings andttimeoutis about key codes. In theory, however, they seem to only differ in that the first is for native mappings and the second is for user-defined mappings. Is that right? – awvalenti Jun 25 '21 at 19:36ttimeoutlento 200 as I had mypastetoggleset to<leader>pand 100ms was too slow (blame old age). I first assumed I should be settingtimeoutlenbut the help forpastetogglesays "When the value has several bytes 'ttimeoutlen' applies." – Anthony Geoghegan Sep 23 '21 at 17:47pastetoggle. Thanks for the tipoff! – Rich Sep 24 '21 at 08:24