Skip to content

Instantly share code, notes, and snippets.

@j2kun
Created August 18, 2022 22:07
Show Gist options
  • Select an option

  • Save j2kun/e5f45f7c5ffe30062581c4bf59fa4fda to your computer and use it in GitHub Desktop.

Select an option

Save j2kun/e5f45f7c5ffe30062581c4bf59fa4fda to your computer and use it in GitHub Desktop.
Open BUILD file in vsplit
function open_build_in_vsplit()
local current_filepath = vim.fn.expand('%:p:h')
local current_filename = vim.fn.expand('%:t')
vim.api.nvim_command('vsp ' .. current_filepath .. "/BUILD")
vim.api.nvim_command('/' .. current_filename)
end
vim.keymap.set('n', '<leader>vb', ':lua open_build_in_vsplit()<CR>')
@j2kun
Copy link
Copy Markdown
Author

j2kun commented Aug 18, 2022

Also see vim.opt.splitright = true

And the slightly more generalized command that drops you into ex mode so you can tabcomplete the filepath/name

vim.keymap.set('n', '<leader>e', ':vsp <C-R>=expand("%:p:h") . "/" <CR>')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment