April 18, 2023

.vimrc file of a writer (not a programmer)

I use Vim as my default editor. Most of my work is done writing and editing in Markdown. Occasionally, I edit scripts or configuration files, but my main usage of Vim remains writing and editing text.

" highlight search term as I type characters /
set incsearch

" Mark folds of Markdown headers 
function! MarkdownFolds()
    let thisline = getline(v:lnum)
    if match(thisline, '^###') >= 0
        return ">3"
    elseif match(thisline, '^##') >= 0
        return ">2"
    elseif match(thisline, '^#') >= 0
        return ">1"
    else
        return "="
    endif
endfunction
setlocal foldmethod=expr
setlocal foldexpr=MarkdownFolds()

I do not use plugins.

I tried but oftentimes plugins came with more functionalities that I needed. I found that the layer of functionalities plugins were introducing was preventing me from understand and learning how Vim functions.

For instance, for a while, I used a Markdown’ plugin that modified Vim by adding a layer of modifications which someone using Markdown would want.
Many of these features were unnecessary to me though, all I wanted was to mark folds of Markdown headers automatically, that is it. Plus the plugin was overriding a native Vim command which I would have liked to use. Eventually, I removed the plugin and looked for a script which only job is to mark folds.


vim personal computing gnu linux trisquel

No affiliate links, no analytics, no tracking, no cookies. This work © 2016-2024 by yctct is licensed under CC BY-ND 4.0 .   about me   contact me   all entries & tags   FAQ   GPG public key

GPG fingerprint: 2E0F FB60 7FEF 11D0 FB45 4DDC E979 E52A 7036 7A88