diff options
Diffstat (limited to 'vim/plugin')
-rw-r--r-- | vim/plugin/big_file_options.vim | 66 | ||||
-rw-r--r-- | vim/plugin/command_typos.vim | 45 | ||||
-rw-r--r-- | vim/plugin/copy_linebreak.vim | 68 | ||||
-rw-r--r-- | vim/plugin/mail_mutt.vim | 56 | ||||
-rw-r--r-- | vim/plugin/strip_trailing_whitespace.vim | 75 |
5 files changed, 0 insertions, 310 deletions
diff --git a/vim/plugin/big_file_options.vim b/vim/plugin/big_file_options.vim deleted file mode 100644 index f7fa0281..00000000 --- a/vim/plugin/big_file_options.vim +++ /dev/null @@ -1,66 +0,0 @@ -" -" big_file_options.vim: When opening a large file, take some measures to keep -" things loading quickly. -" -" Author: Tom Ryder <tom@sanctum.geek.nz> -" License: Same as Vim itself -" -if exists('g:loaded_big_file_options') || &compatible - finish -endif -if !has('autocmd') - finish -endif -let g:loaded_big_file_options = 1 - -" Default threshold is 10 MiB -if !exists('g:big_file_size') - let g:big_file_size = 10 * 1024 * 1024 -endif - -" Default to leaving syntax highlighting off -if !exists('g:big_file_syntax') - let g:big_file_syntax = 0 -endif - -" Cut 'synmaxcol' down to this or smaller for big files -if !exists('g:big_file_synmaxcol') - let g:big_file_synmaxcol = 256 -endif - -" Declare function for turning off slow options -function! s:BigFileOptions() - - " Don't do anything if the buffer size is under the threshold - if line2byte(line('$') + 1) <= g:big_file_size - return - endif - - " Turn off backups, swap files, and undo files - setlocal nobackup - setlocal nowritebackup - setlocal noswapfile - if has('persistent_undo') - setlocal noundofile - endif - - " Limit the number of columns of syntax highlighting - if exists('+synmaxcol') - \ && &synmaxcol > g:big_file_synmaxcol - execute 'setlocal synmaxcol=' . g:big_file_synmaxcol - endif - - " Disable syntax highlighting if configured to do so - if !g:big_file_syntax - setlocal syntax=OFF - endif - -endfunction - -" Define autocmd for calling to check filesize -augroup big_file_options_bufreadpost - autocmd! - autocmd BufReadPost - \ * - \ call s:BigFileOptions() -augroup end diff --git a/vim/plugin/command_typos.vim b/vim/plugin/command_typos.vim deleted file mode 100644 index 6f34c680..00000000 --- a/vim/plugin/command_typos.vim +++ /dev/null @@ -1,45 +0,0 @@ -" -" command_typos.vim: Tolerate typos like :Wq, :Q, or :Qa and do what I mean, -" including any arguments or modifiers; I fat-finger these commands a lot -" because I type them so rapidly, and they don't correspond to any other -" commands I use -" -" Author: Tom Ryder <tom@sanctum.geek.nz> -" License: Same as Vim itself -" -if exists('g:loaded_command_typos') || &compatible - finish -endif -if !has('user_commands') - finish -endif -let g:loaded_command_typos = 1 - -" Define commands -command -bang -complete=file -nargs=? - \ E - \ edit<bang> <args> -command -bang -complete=file -nargs=? - \ W - \ write<bang> <args> -command -bang -complete=file -nargs=? - \ WQ - \ wq<bang> <args> -command -bang -complete=file -nargs=? - \ Wq - \ wq<bang> <args> -command -bang - \ Q - \ quit<bang> -command -bang - \ Qa - \ qall<bang> -command -bang - \ QA - \ qall<bang> -command -bang - \ Wa - \ wall<bang> -command -bang - \ WA - \ wa<bang> diff --git a/vim/plugin/copy_linebreak.vim b/vim/plugin/copy_linebreak.vim deleted file mode 100644 index a7d8a3e5..00000000 --- a/vim/plugin/copy_linebreak.vim +++ /dev/null @@ -1,68 +0,0 @@ -" -" copy_linebreak.vim: Bind user-defined key sequences to toggle a group of -" options that make text wrapped with 'wrap' copy-paste friendly. Also creates -" user commands if it can. -" -" Author: Tom Ryder <tom@sanctum.geek.nz> -" License: Same as Vim itself -" -if exists('g:loaded_copy_linebreak') || &compatible - finish -endif -if !has('linebreak') - finish -endif -let g:loaded_copy_linebreak = 1 - -" Enable copy-friendly linebreak options -function! s:CopyLinebreakEnable() - setlocal nolinebreak linebreak? - let s:showbreak_save = &showbreak - set showbreak= - if exists('+breakindent') - setlocal nobreakindent - endif -endfunction - -" Disable copy-friendly linebreak options -function! s:CopyLinebreakDisable() - setlocal linebreak linebreak? - let &showbreak = s:showbreak_save - if exists('+breakindent') - setlocal breakindent< - endif -endfunction - -" Toggle copy-friendly linebreak options, using the current setting for the -" 'linebreak' option as the pivot -function! s:CopyLinebreakToggle() - if &linebreak - call <SID>CopyLinebreakEnable() - else - call <SID>CopyLinebreakDisable() - endif -endfunction - -" Provide mappings to the function just defined -noremap <silent> <unique> - \ <Plug>CopyLinebreakEnable - \ :<C-U>call <SID>CopyLinebreakEnable()<CR> -noremap <silent> <unique> - \ <Plug>CopyLinebreakDisable - \ :<C-U>call <SID>CopyLinebreakDisable()<CR> -noremap <silent> <unique> - \ <Plug>CopyLinebreakToggle - \ :<C-U>call <SID>CopyLinebreakToggle()<CR> - -" Provide user commands if we can -if has('user_commands') - command -nargs=0 - \ CopyLinebreakEnable - \ call <SID>CopyLinebreakEnable - command -nargs=0 - \ CopyLinebreakDisable - \ call <SID>CopyLinebreakDisable - command -nargs=0 - \ CopyLinebreakToggle - \ call <SID>CopyLinebreakToggle -endif diff --git a/vim/plugin/mail_mutt.vim b/vim/plugin/mail_mutt.vim deleted file mode 100644 index 63cae2f6..00000000 --- a/vim/plugin/mail_mutt.vim +++ /dev/null @@ -1,56 +0,0 @@ -" -" mail_mutt.vim: Start a mutt(1) message with the lines in the given range, -" defaulting to the entire buffer. -" -" Author: Tom Ryder <tom@sanctum.geek.nz> -" License: Same as Vim itself -" -if exists('g:loaded_mail_mutt') || &compatible - finish -endif -if !has('user_commands') - finish -endif -let g:loaded_mail_mutt = 1 - -" Declare function -function! s:MailMutt(start, end) - - " Check we'll have mutt(1) to execute - if !executable('mutt') - echoerr 'mutt not found in $PATH' - finish - endif - - " Create a temporary file - let l:tf = tempname() - - " Write the contents of the buffer to it - let l:range = a:start . ',' . a:end - let l:command = 'write ' . fnameescape(l:tf) - execute l:range . l:command - - " Run mutt(1) with that file as its input - execute '!mutt -i ' . shellescape(l:tf) - -endfunction - -" Create a command to wrap around that function -command -nargs=0 -range=% - \ MailMutt - \ call <SID>MailMutt(<line1>, <line2>) - -" Mapping to mail current line in normal mode -nnoremap <silent> <unique> - \ <Plug>MailMuttLine - \ :<C-U>.MailMutt<CR> - -" Mapping to mail whole buffer in normal mode -nnoremap <silent> <unique> - \ <Plug>MailMuttBuffer - \ :<C-U>%MailMutt<CR> - -" Mapping to mail selected lines in visual/select mode -vnoremap <silent> <unique> - \ <Plug>MailMuttSelected - \ :MailMutt<CR> diff --git a/vim/plugin/strip_trailing_whitespace.vim b/vim/plugin/strip_trailing_whitespace.vim deleted file mode 100644 index 1b6d2f38..00000000 --- a/vim/plugin/strip_trailing_whitespace.vim +++ /dev/null @@ -1,75 +0,0 @@ -" -" strip_trailing_whitespace.vim: User-defined key mapping and optional command -" to strip trailing whitespace in the whole document. -" -" Author: Tom Ryder <tom@sanctum.geek.nz> -" License: Same as Vim itself -" -if exists('g:loaded_strip_trailing_whitespace') || &compatible - finish -endif -let g:loaded_strip_trailing_whitespace = 1 - -" Define function for stripping whitespace -function! s:StripTrailingWhitespace() - - " Iterating line number - let l:li = 1 - - " Line number of last line that had non-whitespace characters on it - let l:lw = 0 - - " Line number of the file's last line - let l:ll = line('$') - - " Iterate over the lines - while l:li <= l:ll - - " Get the line text - let l:line = getline(l:li) - - " Replace the line with a subsitution of its text stripping extraneous - " whitespace - call setline(l:li, substitute(l:line, '\m\C\s\+$', '', 'g')) - - " If this line has any non-whitespace characters on it, update l:lw with - " its index - if l:line =~# '\m\S' - let l:lw = l:li - endif - - " Increment the line counter for the next iteration - let l:li = l:li + 1 - - endwhile - - " If the last non-whitespace line was before the last line proper, we can - " delete all lines after it - if l:lw < l:ll - - " Get the current line and column so we can return to it - " (Yes I know about winsaveview() and winrestview(); I want this to work - " even on very old versions of Vim if possible) - let l:lc = line('.') - let l:cc = col('.') - - " Delete the lines, which will move the cursor - silent execute l:lw + 1 . ',$ delete' - - " Return the cursor to the saved position - call cursor(l:lc, l:cc) - endif - -endfunction - -" Create mapping proxy to the function just defined -noremap <silent> <unique> - \ <Plug>StripTrailingWhitespace - \ :<C-U>call <SID>StripTrailingWhitespace()<CR> - -" Define a user command too, if we can -if has('user_commands') - command -nargs=0 - \ StripTrailingWhiteSpace - \ call <SID>StripTrailingWhitespace() -endif |