]> git.rmz.io Git - dotfiles.git/commitdiff
vim: use scriptease :Vvsplit to open config files
authorSamir Benmendil <me@rmz.io>
Sun, 21 May 2023 09:35:01 +0000 (10:35 +0100)
committerSamir Benmendil <me@rmz.io>
Sun, 17 Dec 2023 17:36:20 +0000 (17:36 +0000)
This works slightly differently as before in that it will not create a
new file if it didn't exist. But it will work for in nvim too.

vim/vimrc

index 7e493fcd1ba16414f60b090c9ff498880c2da85d..a7e23ac7f8ae701c578df0c6038fe7cff384c6be 100644 (file)
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -912,19 +912,16 @@ vnoremap <silent> gs :sort<cr>
 
 " edit configs  {{{2
 function! EditConfig(what, ext = '.vim')
-    let l:dir = split(&runtimepath,',')[0]
     if a:what == 'vimrc'
-        let l:file = expand($MYVIMRC)
-    elseif ! isdirectory(globpath(l:dir, a:what))
-        echoe a:what." is not valid!"
+        let l:file = a:what
     elseif empty(&filetype)
         echoe 'filetype is empty!'
+        return
     else
-        let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
+        let l:file = a:what.'/'.&filetype.a:ext
     endif
 
-    execute ':vsplit '.file
-    execute ':lcd %:p:h'
+    execute ':Vvsplit! '.file
 endf
 nmap <leader>ev :call EditConfig('vimrc')<CR>
 nmap <leader>ef :call EditConfig('ftplugin')<CR>