summaryrefslogtreecommitdiff
path: root/xxx/vim-old/vim-potion/ftplugin/potion/sections.vim
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2021-11-03 19:59:44 +0100
committerMiguel <m.i@gmx.at>2021-11-03 19:59:44 +0100
commitf70d5dc9b1f546bcfae67f067fe2e3b67f94ca45 (patch)
tree3bffaa05b78db0e393bc44eb273f771e08320154 /xxx/vim-old/vim-potion/ftplugin/potion/sections.vim
parente3fb79099e233185825b248a0b275173bd182239 (diff)
improving dotfiles
Diffstat (limited to 'xxx/vim-old/vim-potion/ftplugin/potion/sections.vim')
-rw-r--r--xxx/vim-old/vim-potion/ftplugin/potion/sections.vim47
1 files changed, 47 insertions, 0 deletions
diff --git a/xxx/vim-old/vim-potion/ftplugin/potion/sections.vim b/xxx/vim-old/vim-potion/ftplugin/potion/sections.vim
new file mode 100644
index 0000000..200415c
--- /dev/null
+++ b/xxx/vim-old/vim-potion/ftplugin/potion/sections.vim
@@ -0,0 +1,47 @@
+function! s:NextSection(type, backwards, visual)
+
+ if a:visual
+ normal! gv
+ endif
+
+ if a:type == 1
+ let pattern = '\v(\n\n^\S|%^)'
+ let flags = 'e'
+ elseif a:type == 2
+ let pattern = '\v^\S.*\=.*:$'
+ let flags = ''
+ endif
+
+ if a:backwards
+ let dir = '?'
+ else
+ let dir = '/'
+ endif
+
+ execute 'silent normal! ' . dir . pattern . dir . flags . "\r"
+
+endfunction
+
+noremap <script> <buffer> <silent> ]]
+ \ :call <SID>NextSection(1, 0, 0)<cr>
+
+noremap <script> <buffer> <silent> [[
+ \ :call <SID>NextSection(1, 1, 0)<cr>
+
+noremap <script> <buffer> <silent> ][
+ \ :call <SID>NextSection(2, 0, 0)<cr>
+
+noremap <script> <buffer> <silent> []
+ \ :call <SID>NextSection(2, 1, 0)<cr>
+
+vnoremap <script> <buffer> <silent> ]]
+ \ :<c-u>call <SID>NextSection(1, 0, 1)<cr>
+
+vnoremap <script> <buffer> <silent> [[
+ \ :<c-u>call <SID>NextSection(1, 1, 1)<cr>
+
+vnoremap <script> <buffer> <silent> ][
+ \ :<c-u>call <SID>NextSection(2, 0, 1)<cr>
+
+vnoremap <script> <buffer> <silent> []
+ \ :<c-u>call <SID>NextSection(2, 1, 1)<cr>