Created
July 21, 2025 06:31
-
-
Save kevinma2010/c696cbd06a37c2aa2a3cb70a9b6cab9d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Function to open a terminal on the far right | |
| local function open_term_on_right() | |
| -- Set terminal width to 30% of the editor's width | |
| local percentage = 30 | |
| local width = math.floor(vim.o.columns * (percentage / 100)) | |
| -- Open a terminal in a new vertical split | |
| vim.cmd('vert term') | |
| -- Move focus to the right-most window (the new terminal) | |
| vim.cmd('wincmd L') | |
| -- Resize the terminal window to the calculated width | |
| vim.cmd('vertical resize ' .. width) | |
| end | |
| -- Map <leader>tr to open the terminal in normal mode | |
| vim.keymap.set('n', '<leader>tr', open_term_on_right, { | |
| noremap = true, | |
| silent = true, | |
| desc = "Open terminal on the far right" | |
| }) | |
| -- Map Esc to exit terminal mode and return to normal mode | |
| vim.keymap.set('t', '<Esc>', [[<C-\><C-n>]], { | |
| noremap = true, | |
| silent = true, | |
| desc = "Exit terminal mode" | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment