Created
September 22, 2014 13:00
-
-
Save strokirk/1ed2dcb0c6e7a78811ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function! CountSpaces(line) | |
| return strlen(substitute(a:line, '^ *\zs[^ ].*', '', '')) | |
| endfunction | |
| " Move to the next or previous line with less indent than the current line. | |
| function! IndentSearchLess(dir) | |
| let spaces = CountSpaces(getline('.')) | |
| if spaces == 0 | |
| return | |
| endif | |
| let pattern = '^ \{0,'.(spaces-1).'}[^ ]' | |
| call search(pattern, a:dir . 'eW') | |
| endfunction | |
| " Move to the next or previous line with more indent than the current line. | |
| function! IndentSearchMore(dir) | |
| let spaces = CountSpaces(getline('.')) | |
| let pattern = '^ \{'.(spaces+1).',}[^ ]' | |
| " FIXME: Currenly jumps past dedents | |
| call search(pattern, a:dir . 'eW') | |
| endfunction | |
| " Some basic mappings using the [] standard | |
| nnoremap [f :call IndentSearchLess('b')<cr> | |
| nnoremap ]f :call IndentSearchLess('')<cr> | |
| nnoremap [F :call IndentSearchMore('b')<cr> | |
| nnoremap ]F :call IndentSearchMore('')<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment