Compare commits
10 Commits
Author | SHA1 | Date |
---|---|---|
changeme | 21a5d0b3c1 | |
changeme | 045ccdfa9f | |
changeme | 83005361b6 | |
changeme | 722e2da2f2 | |
Michael Mandl | 97d53cf45c | |
Michael Mandl | 4896a7c3cd | |
Michael Mandl | a7097e7cb8 | |
Michael Mandl | d12fde2ddc | |
mandlm | 7c6d4779f6 | |
mandlm | 15aa4bf864 |
13
README.md
13
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
|
with the corresponding header file in the left window and the corresponding
|
||||||
source file in the right window.
|
source file in the right window.
|
||||||
|
|
||||||
|
Use
|
||||||
|
|
||||||
|
:Split
|
||||||
|
|
||||||
|
to open the corresponding header or source file to your currently open file in
|
||||||
|
a vertical split.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
You can configure the following settings:
|
You can configure the following settings:
|
||||||
|
@ -41,6 +48,12 @@ SplitOpen is GPL-3.0 licensed. See LICENSE file for more info.
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
v1.1.0
|
||||||
|
* Added Split() command
|
||||||
|
|
||||||
|
v1.0.0
|
||||||
|
* Fixed error when reloading plugin
|
||||||
|
|
||||||
v0.0.4
|
v0.0.4
|
||||||
* Add filetype configuraton
|
* Add filetype configuraton
|
||||||
|
|
||||||
|
|
|
@ -4,18 +4,18 @@ function s:invert_dict(source_dict)
|
||||||
let result[value] = key
|
let result[value] = key
|
||||||
endfor
|
endfor
|
||||||
return result
|
return result
|
||||||
endfunc
|
endfunction
|
||||||
|
|
||||||
let s:extensions = g:splitopen_extensions
|
let s:extensions = g:splitopen_extensions
|
||||||
let s:extensions_rev = s:invert_dict(s:extensions)
|
let s:extensions_rev = s:invert_dict(s:extensions)
|
||||||
|
|
||||||
function s:isLeftSideExtension(extension)
|
function s:isLeftSideExtension(extension)
|
||||||
return has_key(s:extensions, a:extension)
|
return has_key(s:extensions, a:extension)
|
||||||
endfunc
|
endfunction
|
||||||
|
|
||||||
function s:isRightSideExtension(extension)
|
function s:isRightSideExtension(extension)
|
||||||
return has_key(s:extensions_rev, a:extension)
|
return has_key(s:extensions_rev, a:extension)
|
||||||
endfunc
|
endfunction
|
||||||
|
|
||||||
function s:getFileExtension(filename)
|
function s:getFileExtension(filename)
|
||||||
return fnamemodify(a:filename, ":e")
|
return fnamemodify(a:filename, ":e")
|
||||||
|
@ -23,7 +23,7 @@ endfunction
|
||||||
|
|
||||||
function s:getFileRoot(filename)
|
function s:getFileRoot(filename)
|
||||||
return fnamemodify(a:filename, ":r")
|
return fnamemodify(a:filename, ":r")
|
||||||
endfunc
|
endfunction
|
||||||
|
|
||||||
function s:getSwitchExtension(filename)
|
function s:getSwitchExtension(filename)
|
||||||
let extension = s:getFileExtension(a:filename)
|
let extension = s:getFileExtension(a:filename)
|
||||||
|
@ -32,25 +32,24 @@ function s:getSwitchExtension(filename)
|
||||||
elseif s:isRightSideExtension(extension)
|
elseif s:isRightSideExtension(extension)
|
||||||
return s:extensions_rev[extension]
|
return s:extensions_rev[extension]
|
||||||
endif
|
endif
|
||||||
endfunc
|
endfunction
|
||||||
|
|
||||||
function s:getSwitchFile(filename)
|
function s:getSwitchFile(filename)
|
||||||
return s:getFileRoot(a:filename) . "." . s:getSwitchExtension(a:filename)
|
return s:getFileRoot(a:filename) . "." . s:getSwitchExtension(a:filename)
|
||||||
endfunc
|
endfunction
|
||||||
|
|
||||||
function s:addLeftSplit(filename)
|
function s:addLeftSplit(filename)
|
||||||
execute("vsplit " . s:getSwitchFile(a:filename))
|
execute("vsplit " . s:getSwitchFile(a:filename))
|
||||||
execute("wincmd l")
|
execute("wincmd l")
|
||||||
endfunc
|
endfunction
|
||||||
|
|
||||||
function s:addRightSplit(filename)
|
function s:addRightSplit(filename)
|
||||||
execute("vsplit " . s:getSwitchFile(a:filename))
|
execute("vsplit " . s:getSwitchFile(a:filename))
|
||||||
execute("wincmd L")
|
execute("wincmd L")
|
||||||
execute("wincmd h")
|
execute("wincmd h")
|
||||||
endfunc
|
endfunction
|
||||||
|
|
||||||
function splitopen#SplitOpenFile(filename)
|
function s:splitOpenFile(filename)
|
||||||
execute("tabedit " . a:filename)
|
|
||||||
let extension = s:getFileExtension(a:filename)
|
let extension = s:getFileExtension(a:filename)
|
||||||
if s:isLeftSideExtension(extension)
|
if s:isLeftSideExtension(extension)
|
||||||
call s:addRightSplit(a:filename)
|
call s:addRightSplit(a:filename)
|
||||||
|
@ -58,3 +57,12 @@ function splitopen#SplitOpenFile(filename)
|
||||||
call s:addLeftSplit(a:filename)
|
call s:addLeftSplit(a:filename)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! splitopen#SplitOpenFile(filename)
|
||||||
|
execute("tabedit " . a:filename)
|
||||||
|
call s:splitOpenFile(a:filename)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! splitopen#SplitFile()
|
||||||
|
call s:splitOpenFile(expand("%:p"))
|
||||||
|
endfunction
|
||||||
|
|
|
@ -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
|
with the corresponding header file in the left window and the corresponding
|
||||||
source file in the right window.
|
source file in the right window.
|
||||||
|
|
||||||
|
Use
|
||||||
|
|
||||||
|
:Split
|
||||||
|
|
||||||
|
to open the corresponding header or source file to your currently open file in
|
||||||
|
a vertical split.
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
2. Configuration *SplitOpenConfiguration*
|
2. Configuration *SplitOpenConfiguration*
|
||||||
|
|
||||||
|
@ -55,6 +62,10 @@ SplitOpen is GPL-3.0 licensed. See LICENSE file for more info.
|
||||||
================================================================================
|
================================================================================
|
||||||
4. Changelog *SplitOpenChangelog*
|
4. Changelog *SplitOpenChangelog*
|
||||||
|
|
||||||
|
v1.1.0
|
||||||
|
* Added Split() command
|
||||||
|
v1.0.0
|
||||||
|
* Fixed error when reloading plugin
|
||||||
v0.0.4
|
v0.0.4
|
||||||
* Add filetype configuraton
|
* Add filetype configuraton
|
||||||
v0.0.3
|
v0.0.3
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
command -nargs=1 SplitOpen :call splitopen#SplitOpenFile("<args>")
|
command! -nargs=1 SplitOpen :call splitopen#SplitOpenFile("<args>")
|
||||||
|
command! Split :call splitopen#SplitFile()
|
||||||
|
|
||||||
" map left-split / right-split file extensions
|
" map left-split / right-split file extensions
|
||||||
if !exists("g:splitopen_extensions")
|
if !exists("g:splitopen_extensions")
|
||||||
|
|
Loading…
Reference in New Issue