Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Small changes make vim/nvim's internal terminal great again !!

License

NotificationsYou must be signed in to change notification settings

skywind3000/vim-terminal-help

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

I use vscode for markdown editing and vscode has aCTRL+backtick hot key to toggle internal terminal. I use it a lot and it's very handy. At the meantime both vim/nvim have internal terminal too, but most of us still prefer working in a tmux split rather than using the internal terminal.

Therefor, I started to wonder, is there something I can do, to make vim's internal terminal has a better experience ? As a result, here this plugin exists with three little changes:

Firstly, this plugin setup a keymapALT+= (can be changed) to toggle terminal window, like vscode'sCTRL+backtick. When you pressALT+= it will open a new terminal below your current window, and initiate the shell working directory to where the parent directory of current file. Most time you want to do something to the current file, so open the shell in the current file directory will make life easier.

When you finished, just pressALT+= again to hide the terminal, so you always pressALT+= to toggle your terminal window, but if you runexit and quit the previous terminal session and hitALT+= again, a new terminal will be created.

In addition, you are able to useALT+SHIFT+h/j/k/l to move around between windows. Most vim users usesCTRL+h/j/k/l for window switching, but these keys are heavily used in the terminal applications, for example if you usetnoremap to overrideCTRL+j orCTRL+k, you will not be able to use them in fzf. SoCTRL+h/j/k/l will not be used fortnoremap,terminal-help encourage you to use the newALT+SHIFT+h/j/k/l to jump between windows.

Finally, it provides adrop command in the internal terminal to tell outside vim to open a file. When you are working in the internal terminal and you want to edit a file in the current directory (not vim'spwd), how do you do ? Especially thepwd in the terminal is different of vim'spwd. You have to switch to terminal normal mode and use vime command with a long path name.

Withdrop command, it is simple to tell outside vim open a specific file precisely:

cd /xxx/some/wheredrop abc.txt

I always believe that small changes can make big difference.

Requirements

  • vim: 8.1
  • neovim: 0.3 and installneovim-remote package if you need the drop command.

Installation

Plug'skywind3000/vim-terminal-help'

Usage

  • ALT +=: toggle terminal below.
  • ALT +SHIFT +h: move to the window on the left.
  • ALT +SHIFT +l: move to the window on the right.
  • ALT +SHIFT +j: move to the window below.
  • ALT +SHIFT +k: move to the window above.
  • ALT +SHIFT +n: move to the previous window.
  • ALT +-: paste register 0 to terminal.
  • ALT +q: switch to terminal normal mode.

Inside the terminal:

drop abc.txt

tell vim to openabc.txt

Command

This plugin provide a single commandH:

:H {shellcommand}

You can type ":H uname -a" in vim's command line, it will send to the terminal directly without actually enter the terminal.

Settings

  • g:terminal_key: which key will be used to toggle terminal window, default to<m-=>.
  • g:terminal_cwd: initialize working dir:0 for unchanged,1 for file path and2 for project root.
  • g:terminal_height: new terminal height, default to 10.
  • g:terminal_pos: where to open the terminal, default torightbelow.
  • g:terminal_shell: specify shell rather than default one.
  • g:terminal_edit: command to open the file in vim, default totab drop.
  • g:terminal_kill: set toterm to kill term session when exiting vim.
  • g:terminal_list: set to 0 to hide terminal buffer in the buffer list.
  • g:terminal_fixheight: set to 1 to setwinfixheight for the terminal window.
  • g:terminal_close: set to 1 to close window if process finished.

Remember

The internal terminal in both vim/neovim hasNORMAL andINSERT mode. When you are inINSERT mode, you can enter shell commands. And if you want to scroll terminal screen or copy / paste texts to a normal vim buffer, you need to switch toNORMAL mode by<c-\><c-n> (like tmux's<c-b> + left square bracket).

This plugin has defined a<m-q> map for<c-\><c-n>, which makes switching to terminal normal mode a little easier.

If you want to re-enterINSERT mode, just pressi ora, and you can input shell commands again.

Integration

This plugin defined a runnerthelp forasyncrun.vim, which enables you use terminal-help to execute asyncrun commands:

:AsyncRun -mode=term -pos=thelpecho123

And it is also useful when you are usingasynctasks.vim:

[test-task]command=echo 123output=terminalpos=thelp

You can either setg:asynctasks_term_pos tothelp or usepos field in task option directly. After this:

:AsyncTask test-task

Can run the task in the terminal-help's window.

About

Small changes make vim/nvim's internal terminal great again !!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors6


[8]ページ先頭

©2009-2025 Movatter.jp