Permalink
Browse files

Move markdown fold expressions into their own file.

  • Loading branch information...
1 parent e905f85 commit c4c8702d3fa55b83ca96cf8ce564e897928b6440 @nelstrom committed Jan 21, 2012
Showing with 52 additions and 56 deletions.
  1. +3 −6 README.markdown
  2. +0 −50 vim/ftplugin/markdown.vim
  3. +49 −0 vim/ftplugin/markdown/folding.vim
View
@@ -24,15 +24,13 @@ be sure, run:
mkdir ~/tmp
-VIM
-===
+# VIM #
My preferences for Vim are stored in `dotfiles/vimrc` and `dotfiles/gvimrc`
respectively. All plugins and scripts are stored in the `dotfiles/vim`
directory.
-Adding Plugin Bundles
----------------------
+## Adding Plugin Bundles ##
Plugins that are published on github can be installed as submodules. For
example, to install the [JavaScript bundle][jsbun], follow these steps:
@@ -66,8 +64,7 @@ it work:
That did the trick.
-RUBY
-====
+# RUBY #
My preferences for IRB customisations are stored in `dotfiles/irbrc`. To get
the most from these, you should install the [interactive_editor][i_editor] and
View
@@ -1,51 +1 @@
setlocal wrap linebreak nolist
-
-function! NestedMarkdownFolds()
- if match(getline(v:lnum), "^#\\{6}") >= 0
- return ">6"
- elseif match(getline(v:lnum), "^#\\{5}") >= 0
- return ">5"
- elseif match(getline(v:lnum), "^#\\{4}") >= 0
- return ">4"
- elseif match(getline(v:lnum), "^#\\{3}") >= 0
- return ">3"
- elseif match(getline(v:lnum), "^#\\{2}") >= 0
- return ">2"
- elseif match(getline(v:lnum), "^#\\{1}") >= 0
- return ">1"
- else
- return "="
- endif
-endfunction
-
-function! FlatMarkdownFolds()
- if match(getline(v:lnum), "^#") >= 0
- return ">1"
- else
- return "="
- endif
-endfunction
-
-function! MarkdownFoldText()
- let foldedlinecount = v:foldend - v:foldstart
- let title = getline( v:foldstart )
- return title . " [" . foldedlinecount . " lines] "
-endfunction
-
-setlocal foldmethod=expr
-setlocal foldexpr=FlatMarkdownFolds()
-setlocal foldtext=MarkdownFoldText()
-
-function! ToggleMarkdownFoldexpr()
- echohl ModeMsg
- if &foldexpr == 'FlatMarkdownFolds()'
- setlocal foldexpr=NestedMarkdownFolds()
- echon 'Nested folding'
- else
- setlocal foldexpr=FlatMarkdownFolds()
- echon 'Flat folding'
- endif
- echohl None
-endfunction
-
-command! -nargs=* FoldToggle call ToggleMarkdownFoldexpr()
@@ -0,0 +1,49 @@
+function! NestedMarkdownFolds()
+ if match(getline(v:lnum), "^#\\{6}") >= 0
+ return ">6"
+ elseif match(getline(v:lnum), "^#\\{5}") >= 0
+ return ">5"
+ elseif match(getline(v:lnum), "^#\\{4}") >= 0
+ return ">4"
+ elseif match(getline(v:lnum), "^#\\{3}") >= 0
+ return ">3"
+ elseif match(getline(v:lnum), "^#\\{2}") >= 0
+ return ">2"
+ elseif match(getline(v:lnum), "^#\\{1}") >= 0
+ return ">1"
+ else
+ return "="
+ endif
+endfunction
+
+function! FlatMarkdownFolds()
+ if match(getline(v:lnum), "^#") >= 0
+ return ">1"
+ else
+ return "="
+ endif
+endfunction
+
+function! MarkdownFoldText()
+ let foldedlinecount = v:foldend - v:foldstart
+ let title = getline( v:foldstart )
+ return title . " [" . foldedlinecount . " lines] "
+endfunction
+
+setlocal foldmethod=expr
+setlocal foldexpr=FlatMarkdownFolds()
+setlocal foldtext=MarkdownFoldText()
+
+function! ToggleMarkdownFoldexpr()
+ echohl ModeMsg
+ if &foldexpr == 'FlatMarkdownFolds()'
+ setlocal foldexpr=NestedMarkdownFolds()
+ echon 'Nested folding'
+ else
+ setlocal foldexpr=FlatMarkdownFolds()
+ echon 'Flat folding'
+ endif
+ echohl None
+endfunction
+
+command! -nargs=* FoldToggle call ToggleMarkdownFoldexpr()

0 comments on commit c4c8702

Please sign in to comment.