Skip to content

Commit 40d433b

Browse files
committed
add function toggle reading mode
1 parent f9bd114 commit 40d433b

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

.vimrc

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ autocmd BufNewFile,BufReadPost *.md set filetype=markdown
6262
autocmd BufNewFile,BufReadPost * if &filetype == "" | setlocal filetype=text | endif
6363

6464
" Set tabstop shiftwidth expandtab listchars
65-
autocmd FileType * set ts=2 | set sw=2 | set et | set lcs=tab:▒░ | set list
65+
autocmd FileType * set ts=2 | set sw=2 | set et | set lcs=tab:▒░ | set list | call s:UpdateReadingMode()
6666
autocmd FileType go,make set noet | set nolist
6767
autocmd FileType go,make,proto,markdown set ts=4 | set sw=4
6868

@@ -125,6 +125,27 @@ nmap <leader>= :vertical resize +2<CR>
125125
" reset all error checking: Stop the highlighting, close locationlist
126126
noremap <esc><esc><esc><esc> :nohl<cr>:lclose<cr>
127127
128+
" reading mode
129+
function! s:UpdateReadingMode()
130+
if exists('t:reading') && t:reading
131+
set nolist
132+
ShowTrailingWhitespaceOff
133+
else
134+
set list
135+
ShowTrailingWhitespaceOn
136+
endif
137+
endfunc
138+
function! s:ToggleReadingMode()
139+
if exists('t:reading') && t:reading
140+
let t:reading = 0
141+
else
142+
let t:reading = 1
143+
endif
144+
call s:UpdateReadingMode()
145+
endfunc
146+
command! ToggleReadingMode call s:ToggleReadingMode()
147+
noremap <space><space><space><space> :ToggleReadingMode<CR>
148+
128149
" =========================================================
129150
set rtp+=~/.vim/bundle/Vundle.vim " set the runtime path to include Vundle and initialize
130151
call vundle#begin('~/.vim/bundle') " Specify a directory for plugins: begin('~/some/path/here')
@@ -216,6 +237,11 @@ let g:multi_cursor_skip_key='<C-x>'
216237
let g:multi_cursor_prev_key='<C-e>'
217238
let g:multi_cursor_quit_key='<Esc>'
218239

240+
" =========================================================
241+
" Configuration: vim-scripts/ShowTrailingWhitespace
242+
command! -bar ShowTrailingWhitespaceOn call ShowTrailingWhitespace#Set(1,1)
243+
command! -bar ShowTrailingWhitespaceOff call ShowTrailingWhitespace#Set(0,1)
244+
219245
" =========================================================
220246
" Configuration: mileszs/ack.vim
221247
" Just like |:Ack| but instead of the |quickfix| list,

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ curl -L https://github.com/modood/vimrc/raw/master/install.sh | bash
1515
| key | description | plugin |
1616
|:----|:------------|:-------|
1717
| `<esc><esc><esc><esc>` | reset all error checking: <br/>1. stop the highlighting<br/>2. close locationlist<br/>3. reset syntastic | - |
18+
| `<space><space><space><space>` | toggle reading mode | - |
1819
| `:w!!` | sudo & write a file | - |
1920
| `<v>` | expand region expand | vim-expand-region |
2021
| `<s>` | s{char} to move to {char} | vim-easymotion |

0 commit comments

Comments
 (0)