From b18fb2ab5efc563b241cf06d1c90075de4a2d361 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Fri, 18 Oct 2019 13:46:00 +0200 Subject: [PATCH 01/17] Split command and function to plugin and autoload parts to enable delay-loading --- plugin/split-open.vim => autoload/splitopen.vim | 4 +--- plugin/splitopen.vim | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) rename plugin/split-open.vim => autoload/splitopen.vim (74%) create mode 100644 plugin/splitopen.vim diff --git a/plugin/split-open.vim b/autoload/splitopen.vim similarity index 74% rename from plugin/split-open.vim rename to autoload/splitopen.vim index 43992db..d4f2aac 100644 --- a/plugin/split-open.vim +++ b/autoload/splitopen.vim @@ -1,4 +1,4 @@ -function! SplitOpenFile(filename) +function splitopen#SplitOpenFile(filename) execute("tabedit " . a:filename) let l:file_extension = tolower(fnamemodify(a:filename, ":e")) if l:file_extension == "cpp" @@ -9,5 +9,3 @@ function! SplitOpenFile(filename) execute("wincmd h") endif endfunction - -command! -nargs=1 SplitOpen :call SplitOpenFile("") diff --git a/plugin/splitopen.vim b/plugin/splitopen.vim new file mode 100644 index 0000000..9036e30 --- /dev/null +++ b/plugin/splitopen.vim @@ -0,0 +1 @@ +command -nargs=1 SplitOpen :call splitopen#SplitOpenFile("") From 8b92df058a870befc218bd9d9e2e38b608981a1f Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Fri, 18 Oct 2019 14:47:52 +0200 Subject: [PATCH 02/17] Added documentation --- doc/splitopen.txt | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 doc/splitopen.txt diff --git a/doc/splitopen.txt b/doc/splitopen.txt new file mode 100644 index 0000000..a4ef787 --- /dev/null +++ b/doc/splitopen.txt @@ -0,0 +1,30 @@ +*splitopen.txt* opens file-pairs in a new split-window tab + +================================================================================ +CONTENTS *SplitOpenContents* + + 1. Usage ..................................|SplitOpenUsage| + 2. License ................................|SplitOpenLicense| + 3. Changelog ..............................|SplitOpenChangelog| + +================================================================================ +1. Usage *SplitOpenUsage* + +Use + + :SplitOpen filename + +with a .cpp or .h file as filename to open a new tab containing a vertical split +with the corresponding header file in the left window and the corresponding +source file in the right window. + +================================================================================ +2. License *SplitOpenLicense* + +SplitOpen is GPL-3.0 licensed. See LICENSE file for more info. + +================================================================================ +3. Changelog *SplitOpenChangelog* + +v0.0.1 + * Initial release From b690d216d2953798ac3faf7f9e13390f27a6e4e7 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Fri, 18 Oct 2019 14:53:12 +0200 Subject: [PATCH 03/17] Updated release notes --- doc/splitopen.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/splitopen.txt b/doc/splitopen.txt index a4ef787..66af367 100644 --- a/doc/splitopen.txt +++ b/doc/splitopen.txt @@ -26,5 +26,9 @@ SplitOpen is GPL-3.0 licensed. See LICENSE file for more info. ================================================================================ 3. Changelog *SplitOpenChangelog* +v0.0.2 + * Added delay-loading + * Added documentation + v0.0.1 * Initial release From 48cdd5b9d745555a7a51542785c07548ed0cb1ba Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Fri, 18 Oct 2019 20:17:35 +0200 Subject: [PATCH 04/17] Updated readme from doc --- README.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4cd4129..957bf6a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,26 @@ -# vim-split-open +# SplitOpen -This is my first vim plugin. It provides a command to open a combination of c++ source and header file in a new tab split side-by-side. +This vim plugin opens file-pairs in a new split-window tab + +## Usage + +Use + + :SplitOpen filename + +with a .cpp or .h file as filename to open a new tab containing a vertical split +with the corresponding header file in the left window and the corresponding +source file in the right window. + +## License + +SplitOpen is GPL-3.0 licensed. See LICENSE file for more info. + +## Changelog + +v0.0.2 +* Added delay-loading +* Added documentation + +v0.0.1 +* Initial release From c170d0779f5ca58625bbd66c4ddf59688064c4c6 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Fri, 18 Oct 2019 16:17:49 +0200 Subject: [PATCH 05/17] Set fzf.vim keybinding (dangerous) --- plugin/splitopen.vim | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugin/splitopen.vim b/plugin/splitopen.vim index 9036e30..f7741dc 100644 --- a/plugin/splitopen.vim +++ b/plugin/splitopen.vim @@ -1 +1,8 @@ command -nargs=1 SplitOpen :call splitopen#SplitOpenFile("") + +let g:fzf_action = { + \ 'ctrl-s': 'SplitOpen', + \ 'ctrl-t': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-v': 'vsplit' } + From a2736f4579513921f06a1e8bdc9132290f2b58e4 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Fri, 18 Oct 2019 20:57:12 +0200 Subject: [PATCH 06/17] Added config option g:splitopen_set_fzf_keys to enable fzf keybinding. Disabled by default. --- README.md | 14 ++++++++++++++ doc/splitopen.txt | 28 +++++++++++++++++++++++----- plugin/splitopen.vim | 15 ++++++++++----- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 957bf6a..318fd50 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,20 @@ with a .cpp or .h file as filename to open a new tab containing a vertical split with the corresponding header file in the left window and the corresponding source file in the right window. +## Configuration + +You can configure the following settings: + + +### g:splitopen_set_fzf_keys + +Set this option to 1 + + let g:splitopen_set_fzf_keys = 1 + +to have SplitOpen overwrite the default fzf keybindings ctrl-t/x/v for opening +files in splits or tabs to add an addional binding ctrl-s to call SplitOpen. + ## License SplitOpen is GPL-3.0 licensed. See LICENSE file for more info. diff --git a/doc/splitopen.txt b/doc/splitopen.txt index 66af367..f7da20a 100644 --- a/doc/splitopen.txt +++ b/doc/splitopen.txt @@ -3,9 +3,11 @@ ================================================================================ CONTENTS *SplitOpenContents* - 1. Usage ..................................|SplitOpenUsage| - 2. License ................................|SplitOpenLicense| - 3. Changelog ..............................|SplitOpenChangelog| + 1. Usage ..............................|SplitOpenUsage| + 2. Configuration ......................|SlitOpenConfiguraton| + 2.1 g:splitopen_set_fzf_keys.......|SplitOpenConfiguration_set_fzf_keys| + 3. License ............................|SplitOpenLicense| + 4. Changelog ..........................|SplitOpenChangelog| ================================================================================ 1. Usage *SplitOpenUsage* @@ -19,12 +21,28 @@ with the corresponding header file in the left window and the corresponding source file in the right window. ================================================================================ -2. License *SplitOpenLicense* +2. Configuration *SplitOpenConfiguration* + +You can configure the following settings: + +-------------------------------------------------------------------------------- + +2.1 g:splitopen_set_fzf_keys *SplitOpenConfiguration_set_fzf_keys* + +Set this option to 1 + + let g:splitopen_set_fzf_keys = 1 + +to have SplitOpen overwrite the default fzf keybindings ctrl-t/x/v for opening +files in splits or tabs to add an addional binding ctrl-s to call SplitOpen. + +================================================================================ +3. License *SplitOpenLicense* SplitOpen is GPL-3.0 licensed. See LICENSE file for more info. ================================================================================ -3. Changelog *SplitOpenChangelog* +4. Changelog *SplitOpenChangelog* v0.0.2 * Added delay-loading diff --git a/plugin/splitopen.vim b/plugin/splitopen.vim index f7741dc..91cabdd 100644 --- a/plugin/splitopen.vim +++ b/plugin/splitopen.vim @@ -1,8 +1,13 @@ command -nargs=1 SplitOpen :call splitopen#SplitOpenFile("") -let g:fzf_action = { - \ 'ctrl-s': 'SplitOpen', - \ 'ctrl-t': 'tab split', - \ 'ctrl-x': 'split', - \ 'ctrl-v': 'vsplit' } +if !exists('g:splitopen_set_fzf_keys') + let g:splitopen_set_fzf_keys = 0 +endif +if g:splitopen_set_fzf_keys + let g:fzf_action = { + \ 'ctrl-s': 'SplitOpen', + \ 'ctrl-t': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-v': 'vsplit' } +endif From 657fc628d57c6d2ef8349774978fe1ed3def9f42 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Fri, 18 Oct 2019 21:05:08 +0200 Subject: [PATCH 07/17] Updated changelog --- README.md | 3 +++ doc/splitopen.txt | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 318fd50..823c8a7 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,9 @@ SplitOpen is GPL-3.0 licensed. See LICENSE file for more info. ## Changelog +v0.0.3 +* Add fzf.vim keybinding + v0.0.2 * Added delay-loading * Added documentation diff --git a/doc/splitopen.txt b/doc/splitopen.txt index f7da20a..c4b3e6e 100644 --- a/doc/splitopen.txt +++ b/doc/splitopen.txt @@ -44,9 +44,10 @@ SplitOpen is GPL-3.0 licensed. See LICENSE file for more info. ================================================================================ 4. Changelog *SplitOpenChangelog* +v0.0.3 + * Add fzf.vim keybinding v0.0.2 * Added delay-loading * Added documentation - v0.0.1 * Initial release From b842eb4a488c38c740cfb011de808eeeb83513d9 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 20 Oct 2019 13:55:10 +0200 Subject: [PATCH 08/17] Replace FSwitch call with vimscript --- autoload/splitopen.vim | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/autoload/splitopen.vim b/autoload/splitopen.vim index d4f2aac..98aa3b0 100644 --- a/autoload/splitopen.vim +++ b/autoload/splitopen.vim @@ -1,11 +1,28 @@ +function s:getFileExtension(filename) + return fnamemodify(a:filename, ":e") +endfunction + +function s:getFileRoot(filename) + return fnamemodify(a:filename, ":r") +endfunc + +function s:getSwitchExtension(extension) + if (a:extension == "cpp") + return "h" + elseif (a:extension == "h") + return "cpp" + endif +endfunc + +function s:getSwitchFile(filename) + return s:getFileRoot(a:filename) . "." . s:getSwitchExtension(s:getFileExtension(a:filename)) +endfunc + +function s:addLeftSplit(filename) + execute("vsplit " . s:getSwitchFile(a:filename)) +endfunc + function splitopen#SplitOpenFile(filename) execute("tabedit " . a:filename) - let l:file_extension = tolower(fnamemodify(a:filename, ":e")) - if l:file_extension == "cpp" - execute("FSSplitLeft") - execute("wincmd l") - elseif l:file_extension == "h" - execute("FSSplitRight") - execute("wincmd h") - endif + call s:addLeftSplit(a:filename) endfunction From cd2d19844798ecc18381c2336ea3362eca1a0bfb Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 20 Oct 2019 15:39:32 +0200 Subject: [PATCH 09/17] Define left- and right-hand filetypes via global config variable --- autoload/splitopen.vim | 46 +++++++++++++++++++++++++++++++++++------- plugin/splitopen.vim | 11 +++++++++- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/autoload/splitopen.vim b/autoload/splitopen.vim index 98aa3b0..b4488ba 100644 --- a/autoload/splitopen.vim +++ b/autoload/splitopen.vim @@ -1,3 +1,22 @@ +function s:invert_dict(source_dict) + let result = {} + for [key, value] in items(a:source_dict) + let result[value] = key + endfor + return result +endfunc + +let s:extensions = g:splitopen_extensions +let s:extensions_rev = s:invert_dict(s:extensions) + +function s:isLeftSideExtension(extension) + return has_key(s:extensions, a:extension) +endfunc + +function s:isRightSideExtension(extension) + return has_key(s:extensions_rev, a:extension) +endfunc + function s:getFileExtension(filename) return fnamemodify(a:filename, ":e") endfunction @@ -6,23 +25,36 @@ function s:getFileRoot(filename) return fnamemodify(a:filename, ":r") endfunc -function s:getSwitchExtension(extension) - if (a:extension == "cpp") - return "h" - elseif (a:extension == "h") - return "cpp" +function s:getSwitchExtension(filename) + let extension = s:getFileExtension(a:filename) + if s:isLeftSideExtension(extension) + return s:extensions[extension] + elseif s:isRightSideExtension(extension) + return s:extensions_rev[extension] endif endfunc function s:getSwitchFile(filename) - return s:getFileRoot(a:filename) . "." . s:getSwitchExtension(s:getFileExtension(a:filename)) + return s:getFileRoot(a:filename) . "." . s:getSwitchExtension(a:filename) endfunc function s:addLeftSplit(filename) execute("vsplit " . s:getSwitchFile(a:filename)) + execute("wincmd l") +endfunc + +function s:addRightSplit(filename) + execute("vsplit " . s:getSwitchFile(a:filename)) + execute("wincmd L") + execute("wincmd h") endfunc function splitopen#SplitOpenFile(filename) execute("tabedit " . a:filename) - call s:addLeftSplit(a:filename) + let extension = s:getFileExtension(a:filename) + if s:isLeftSideExtension(extension) + call s:addRightSplit(a:filename) + elseif s:isRightSideExtension(extension) + call s:addLeftSplit(a:filename) + endif endfunction diff --git a/plugin/splitopen.vim b/plugin/splitopen.vim index 91cabdd..7f54b02 100644 --- a/plugin/splitopen.vim +++ b/plugin/splitopen.vim @@ -1,5 +1,13 @@ command -nargs=1 SplitOpen :call splitopen#SplitOpenFile("") +" map left-split / right-split file extensions +if !exists("g:splitopen_extensions") + let g:splitopen_extensions = { + \ "h": "cpp", + \ "H": "CPP", + \ } +endif + if !exists('g:splitopen_set_fzf_keys') let g:splitopen_set_fzf_keys = 0 endif @@ -9,5 +17,6 @@ if g:splitopen_set_fzf_keys \ 'ctrl-s': 'SplitOpen', \ 'ctrl-t': 'tab split', \ 'ctrl-x': 'split', - \ 'ctrl-v': 'vsplit' } + \ 'ctrl-v': 'vsplit', + \ } endif From b6b1377f93b771e8538b47b1136a3575a8fc0640 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 20 Oct 2019 15:45:53 +0200 Subject: [PATCH 10/17] Added documentation for g:splitopen_extensions --- README.md | 9 +++++++++ doc/splitopen.txt | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 823c8a7..8481b70 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,15 @@ source file in the right window. You can configure the following settings: +### g:splitopen_extensions + +Use this dictionary to define your pairs of left-hand- right-hand-side file +types. E.g. + + let g:splitopen_extensions = {"h": "cpp"} + +always places a .cpp file on the right-hand side when opening an .h file and +vice versa. ### g:splitopen_set_fzf_keys diff --git a/doc/splitopen.txt b/doc/splitopen.txt index c4b3e6e..39cb2a6 100644 --- a/doc/splitopen.txt +++ b/doc/splitopen.txt @@ -5,7 +5,8 @@ CONTENTS *SplitOpenContents* 1. Usage ..............................|SplitOpenUsage| 2. Configuration ......................|SlitOpenConfiguraton| - 2.1 g:splitopen_set_fzf_keys.......|SplitOpenConfiguration_set_fzf_keys| + 2.1 g:splitopen_extensions.........|SplitOpenConfiguration_extensions| + 2.2 g:splitopen_set_fzf_keys.......|SplitOpenConfiguration_set_fzf_keys| 3. License ............................|SplitOpenLicense| 4. Changelog ..........................|SplitOpenChangelog| @@ -27,7 +28,19 @@ You can configure the following settings: -------------------------------------------------------------------------------- -2.1 g:splitopen_set_fzf_keys *SplitOpenConfiguration_set_fzf_keys* +2.1 g:splitopen_extensions *SplitOpenConfiguration_extensions* + +Use this dictionary to define your pairs of left-hand- right-hand-side file +types. E.g. + + let g:splitopen_extensions = {"h": "cpp"} + +always places a .cpp file on the right-hand side when opening an .h file and +vice versa. + +-------------------------------------------------------------------------------- + +2.2 g:splitopen_set_fzf_keys *SplitOpenConfiguration_set_fzf_keys* Set this option to 1 From a6f8b0fda5c36c236b864d3b9a2bc9580cfab1e6 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 20 Oct 2019 15:48:05 +0200 Subject: [PATCH 11/17] Formatting --- doc/splitopen.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/splitopen.txt b/doc/splitopen.txt index 39cb2a6..ef3aa40 100644 --- a/doc/splitopen.txt +++ b/doc/splitopen.txt @@ -27,7 +27,6 @@ source file in the right window. You can configure the following settings: -------------------------------------------------------------------------------- - 2.1 g:splitopen_extensions *SplitOpenConfiguration_extensions* Use this dictionary to define your pairs of left-hand- right-hand-side file @@ -39,7 +38,6 @@ always places a .cpp file on the right-hand side when opening an .h file and vice versa. -------------------------------------------------------------------------------- - 2.2 g:splitopen_set_fzf_keys *SplitOpenConfiguration_set_fzf_keys* Set this option to 1 From d91bb228a7e1f2ed4a32f67b1e03866806e23172 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 20 Oct 2019 15:53:29 +0200 Subject: [PATCH 12/17] Added release notes --- README.md | 3 +++ doc/splitopen.txt | 2 ++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 8481b70..9418060 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,9 @@ SplitOpen is GPL-3.0 licensed. See LICENSE file for more info. ## Changelog +v0.0.4 +* Add filetype configuraton + v0.0.3 * Add fzf.vim keybinding diff --git a/doc/splitopen.txt b/doc/splitopen.txt index ef3aa40..55e954d 100644 --- a/doc/splitopen.txt +++ b/doc/splitopen.txt @@ -55,6 +55,8 @@ SplitOpen is GPL-3.0 licensed. See LICENSE file for more info. ================================================================================ 4. Changelog *SplitOpenChangelog* +v0.0.4 + * Add filetype configuraton v0.0.3 * Add fzf.vim keybinding v0.0.2 From 7c6d4779f68f2243dbb46342db94ae6654e5ebd7 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Tue, 22 Oct 2019 19:01:14 +0200 Subject: [PATCH 13/17] Overwrite exported command and function, used endfunction instead of endfunc --- autoload/splitopen.vim | 18 +++++++++--------- plugin/splitopen.vim | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/autoload/splitopen.vim b/autoload/splitopen.vim index b4488ba..278a532 100644 --- a/autoload/splitopen.vim +++ b/autoload/splitopen.vim @@ -4,18 +4,18 @@ function s:invert_dict(source_dict) let result[value] = key endfor return result -endfunc +endfunction let s:extensions = g:splitopen_extensions let s:extensions_rev = s:invert_dict(s:extensions) function s:isLeftSideExtension(extension) return has_key(s:extensions, a:extension) -endfunc +endfunction function s:isRightSideExtension(extension) return has_key(s:extensions_rev, a:extension) -endfunc +endfunction function s:getFileExtension(filename) return fnamemodify(a:filename, ":e") @@ -23,7 +23,7 @@ endfunction function s:getFileRoot(filename) return fnamemodify(a:filename, ":r") -endfunc +endfunction function s:getSwitchExtension(filename) let extension = s:getFileExtension(a:filename) @@ -32,24 +32,24 @@ function s:getSwitchExtension(filename) elseif s:isRightSideExtension(extension) return s:extensions_rev[extension] endif -endfunc +endfunction function s:getSwitchFile(filename) return s:getFileRoot(a:filename) . "." . s:getSwitchExtension(a:filename) -endfunc +endfunction function s:addLeftSplit(filename) execute("vsplit " . s:getSwitchFile(a:filename)) execute("wincmd l") -endfunc +endfunction function s:addRightSplit(filename) execute("vsplit " . s:getSwitchFile(a:filename)) execute("wincmd L") execute("wincmd h") -endfunc +endfunction -function splitopen#SplitOpenFile(filename) +function! splitopen#SplitOpenFile(filename) execute("tabedit " . a:filename) let extension = s:getFileExtension(a:filename) if s:isLeftSideExtension(extension) diff --git a/plugin/splitopen.vim b/plugin/splitopen.vim index 7f54b02..ed08d08 100644 --- a/plugin/splitopen.vim +++ b/plugin/splitopen.vim @@ -1,4 +1,4 @@ -command -nargs=1 SplitOpen :call splitopen#SplitOpenFile("") +command! -nargs=1 SplitOpen :call splitopen#SplitOpenFile("") " map left-split / right-split file extensions if !exists("g:splitopen_extensions") From d12fde2ddcdc1e1eadac1b663208a372f4a5d1d4 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Wed, 30 Oct 2019 22:21:59 +0100 Subject: [PATCH 14/17] Updated release notes --- README.md | 3 +++ doc/splitopen.txt | 2 ++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 9418060..3f831cf 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,9 @@ SplitOpen is GPL-3.0 licensed. See LICENSE file for more info. ## Changelog +v1.0.0 +* Fixed error when reloading plugin + v0.0.4 * Add filetype configuraton diff --git a/doc/splitopen.txt b/doc/splitopen.txt index 55e954d..30cf547 100644 --- a/doc/splitopen.txt +++ b/doc/splitopen.txt @@ -55,6 +55,8 @@ SplitOpen is GPL-3.0 licensed. See LICENSE file for more info. ================================================================================ 4. Changelog *SplitOpenChangelog* +v1.0.0 + * Fixed error when reloading plugin v0.0.4 * Add filetype configuraton v0.0.3 From 97d53cf45c001f8026cf96c4b9065372b2d4bf27 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Wed, 30 Oct 2019 22:40:30 +0100 Subject: [PATCH 15/17] Added new Split() command to split an existing tab --- autoload/splitopen.vim | 12 ++++++++++-- plugin/splitopen.vim | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/autoload/splitopen.vim b/autoload/splitopen.vim index 278a532..1151120 100644 --- a/autoload/splitopen.vim +++ b/autoload/splitopen.vim @@ -49,8 +49,7 @@ function s:addRightSplit(filename) execute("wincmd h") endfunction -function! splitopen#SplitOpenFile(filename) - execute("tabedit " . a:filename) +function s:splitOpenFile(filename) let extension = s:getFileExtension(a:filename) if s:isLeftSideExtension(extension) call s:addRightSplit(a:filename) @@ -58,3 +57,12 @@ function! splitopen#SplitOpenFile(filename) call s:addLeftSplit(a:filename) endif endfunction + +function! splitopen#SplitOpenFile(filename) + execute("tabedit " . a:filename) + call s:splitOpenFile(a:filename) +endfunction + +function! splitopen#SplitFile() + call s:splitOpenFile(expand("%:p")) +endfunction diff --git a/plugin/splitopen.vim b/plugin/splitopen.vim index ed08d08..2534fdb 100644 --- a/plugin/splitopen.vim +++ b/plugin/splitopen.vim @@ -1,4 +1,5 @@ command! -nargs=1 SplitOpen :call splitopen#SplitOpenFile("") +command! Split :call splitopen#SplitFile() " map left-split / right-split file extensions if !exists("g:splitopen_extensions") From 722e2da2f2788cb95bb90a7f40e1115667eb37cd Mon Sep 17 00:00:00 2001 From: changeme Date: Mon, 29 Jun 2020 21:28:07 +0200 Subject: [PATCH 16/17] Added release documentation --- README.md | 10 ++++++++++ doc/splitopen.txt | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/README.md b/README.md index 3f831cf..5bde54f 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,13 @@ with a .cpp or .h file as filename to open a new tab containing a vertical split with the corresponding header file in the left window and the corresponding source file in the right window. +Use + + :Split + +to open the corresponding heder or source file to your currently open file in +a vertical split. + ## Configuration You can configure the following settings: @@ -41,6 +48,9 @@ SplitOpen is GPL-3.0 licensed. See LICENSE file for more info. ## Changelog +v1.1.0 +* Added Split() command + v1.0.0 * Fixed error when reloading plugin diff --git a/doc/splitopen.txt b/doc/splitopen.txt index 30cf547..e8e9c6c 100644 --- a/doc/splitopen.txt +++ b/doc/splitopen.txt @@ -21,6 +21,13 @@ with a .cpp or .h file as filename to open a new tab containing a vertical split with the corresponding header file in the left window and the corresponding source file in the right window. +Use + + :Split + +to open the corresponding heder or source file to your currently open file in +a vertical split. + ================================================================================ 2. Configuration *SplitOpenConfiguration* @@ -55,6 +62,8 @@ SplitOpen is GPL-3.0 licensed. See LICENSE file for more info. ================================================================================ 4. Changelog *SplitOpenChangelog* +v1.1.0 + * Added Split() command v1.0.0 * Fixed error when reloading plugin v0.0.4 From 045ccdfa9f0af738f8888d3f4efc55b4b0395422 Mon Sep 17 00:00:00 2001 From: changeme Date: Mon, 29 Jun 2020 21:30:19 +0200 Subject: [PATCH 17/17] Fixed a typo --- README.md | 2 +- doc/splitopen.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5bde54f..d1bd33f 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Use :Split -to open the corresponding heder or source file to your currently open file in +to open the corresponding header or source file to your currently open file in a vertical split. ## Configuration diff --git a/doc/splitopen.txt b/doc/splitopen.txt index e8e9c6c..8d64698 100644 --- a/doc/splitopen.txt +++ b/doc/splitopen.txt @@ -25,7 +25,7 @@ Use :Split -to open the corresponding heder or source file to your currently open file in +to open the corresponding header or source file to your currently open file in a vertical split. ================================================================================