Skip to main content
7 of 7
added 223 characters in body
Martin Tournoij
  • 63.3k
  • 26
  • 199
  • 274

You can map FloatTermNew <cmd> in an autocmd for specific filetypes:

augroup floatterm-mappings
    au!
    au FileType javascript nnoremap <buffer> <F5> :w<esc>:FloatermNew node %<CR>
    au FileType c          nnoremap <buffer> <F5> :w<esc>:FloatermNew gcc % && ./a.out && rm a.out<CR>
    au FileType cpp        nnoremap <buffer> <F5> :w<esc>:FloatermNew g++ % && ./a.out && rm a.out<CR>
    au FileType python     nnoremap <buffer> <F5> :w<esc>:FloatermNew python3 %<CR>
augroup end

The <buffer> in nnoremap makes sure the mapping only works for that specific buffer (rather than all buffers).

Visrut
  • 125
  • 6