4

If I execute a interactive command with :terminal, buffername will be something like: term://.//1234:command executed here with params.

I want to be able to change it to something more meaningful to use with my fork for vim-vroom. Here is the snippet for reference:

function s:RunNeoTerminal(cmd)
  " close previous openned buffer
  if exists('t:vroom_terminal_bufnr') && bufexists(t:vroom_terminal_bufnr)
    exec ":bd! ".t:vroom_terminal_bufnr
  end

  let height = winheight(0) * 1/4
  exec ":belowright " . height . "split"

  exec ":terminal " . a:cmd
  " terminal runs by default in insert mode which kills the buffer after exit,
  " let's change to normal mode
  exec ":stopinsert"
  let t:vroom_terminal_bufnr = bufnr('%')
endfunction

https://github.com/brodock/vim-vroom/blob/neovim-terminal/autoload/vroom.vim#L253-L267

1 Answer 1

7

You can change the name of any buffer by using the :file {name} command. However, doing so changes that alternate-file to the previous name, which you may not want in this case. The :keepalt command avoids that issue.

Putting it all together, this should do what you want

keepalt file meaningful

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.