5 Comments
- lowkey, on 10/12/2007, -0/+4Ok a 1 minute time to replace all the symbols is a joke. one last try.
For the spellcheck toggle, the nnoremap line should read:
nnoremap <silent> <F7> <ESC>:call <SID>ToggleSpell()<CR>
And the complete Python function should read like:
function! s:MyPythonSettings()
setlocal autoindent
let python_highlight_all=1
let python_space_errors=1
let python_no_tab_space_error=1
" load pydiction complete file
set complete+=k/home/lowkey/.vim/pydiction
set isk+="i.,("
" Insert comments markers
map - :s/^/#/<CR>:nohlsearch<CR>
" Insert wrapping comments around a single line
map { :s/^(.*)$/"""n1n"""/<CR>:nohlsearch<CR>
if !exists("g:loaded_pygrep")
function! PythonGrep(tool)
set lazyredraw
" Close any existing cwindows.
cclose
let l:grepformat_save = &grepformat
let l:grepprogram_save = &grepprg
set grepformat&vim
set grepformat&vim
let &grepformat = '%f:%l:%m'
if a:tool == "pylint"
let &grepprg = 'pylint --parseable=y --reports=n'
elseif a:tool == "pychecker"
let &grepprg = 'pychecker --quiet -q'
else
echohl WarningMsg
echo "PythonGrep Error: Unknown Tool"
echohl none
endif
if &readonly == 0 | update | endif
silent! grep! %
let &grepformat = l:grepformat_save
let &grepprg = l:grepprogram_save
let l:mod_total = 0
let l:win_count = 1
" Determine correct window height
windo let l:win_count = l:win_count + 1
if l:win_count <= 2 | let l:win_count = 4 | endif
windo let l:mod_total = l:mod_total + winheight(0)/l:win_count |
execute 'resize +'.l:mod_total
" Open cwindow
execute 'belowright copen '.l:mod_total
nnoremap c :cclose
nnoremap q :cclose
set nobuflisted
set nolazyredraw
redraw!
endfunction
if ( !hasmapto('PythonGrep(pylint)') && (maparg('') == '') )
map <F3> :call <SID>PythonGrep('pylint')<CR>
map! <F3> :call <SID>PythonGrep('pylint')<CR>
else
if ( !has("gui_running") || has("win32") )
echo "Python Pylint Error: No Key mapped.n".
"F3 is taken and a replacement was not assigned."
endif
endif
if ( !hasmapto('PythonGrep(pychecker)') && (maparg('') == '') )
map <F4> :call <SID>PythonGrep('pychecker')<CR>
map! <F4> :call <SID>PythonGrep('pychecker')<CR>
else
if ( !has("gui_running") || has("win32") )
echo "Python Pychecker Error: No Key mapped.n".
"F4 is taken and a replacement was not assigned."
endif
endif
let g:loaded_pygrep=1
endif
endfunction
function! s:MyShellSettings()
set commentstring=# %s
set formatoptions=croq2lv
" Insert comments markers
map - :s/^/#/<CR>:nohlsearch<CR>
" Syntax file options
let highlight_function_name = 1
endfunction
function! s:MyVimSettings()
set commentstring=" %s
setlocal tabstop=4
setlocal shiftwidth=4
" Insert comments markers
map - :s/^/"/<CR>:nohlsearch<CR>
" Source vimrc and files in .vim/[colors,indentplugin] after saving them
" (vimtip#879).
augroup vimrc_vim
autocmd! bufwritepost ~/.vimrc source ~/.vimrc
autocmd! bufwritepost ~/.vim/colors/*.vim exec 'source ' . expand("%:p")
autocmd! bufwritepost ~/.vim/indent/*.vim exec 'source ' . expand("%:p")
autocmd! bufwritepost ~/.vim/plugin/*.vim exec 'source ' . expand("%:p")
augroup end
endfunction
OK that should do it. As they say no good deed goes unpunished. - lowkey, on 10/12/2007, -1/+3incremental search? scrolloff? wildmode?
Customizations for beginners maybe.
For a lot more and cooler stuff look at http://www.vim.org/tips/index.php and http://www.vim.org/scripts/index.php.
For example VimTip# 498 describes how to use the syntax files to enable language specific tab completion liike so:
augroup vimrc_keyword
autocmd!
autocmd FileType * exec( 'setlocal dict+=' . $VIMRUNTIME . '/syntax/'
. expand('') . '.vim' )
augroup end
Or you can toggle spellcheck in Vim7 with:
if v:version >= 700
function! ToggleSpell()
if &spell != 1
setlocal spell spelllang=en_us
else
setlocal spell!
endif
endfunction
nnoremap :call ToggleSpell()
setlocal spell spelllang=en_us
endif
now just press F7 to see all those misspellings highlighted.
Or trim all blank spaces off the ends of all lines by pressing F12:
map mz:%s/s*$//g:nohlsearch`z
Or my favorite, load filetype specific settings automagically as the file loads:
augroup vimrc_filetype
autocmd!
autocmd BufReadPre *.doc set filetype="msword"
autocmd BufReadPost *.doc silent %!antiword "%"
autocmd FileType c call s:MyCSettings()
autocmd FileType perl call s:MyPerlSettings()
autocmd FileType python call s:MyPythonSettings()
autocmd FileType sh call s:MyShellSettings()
autocmd FileType vim call s:MyVimSettings()
augroup end
function! s:MyCSettings()
set cindent
let c_gnu = 1
let c_comment_strings = 1
let c_no_if0 = 1
let c_space_errors = 1
let c_syntax_for_h = 1
endfunction
function! s:MyMSWordSettings()
" Must have Antiword (URL: http://www.winfield.demon.nl/)
" or Catdoc (http://www.45.free.net/~vitus/ice/catdoc/)
" (vimtip#790)
" also look into unrtf http://www.gnu.org/software/unrtf/unrtf.html
set readonly
set hlsearch!
endfunction
function! s:MyPerlSettings()
set autowrite
" set errorformat=%f:%l:%m
set formatoptions=croq
set keywordprg=man -S 3
let perl_want_scope_in_variables = 1
let perl_extended_vars = 1
"set makeprg=/usr/share/doc/vim/tools/efm_perl.pl -c % $*
noremap :call Executor()
endfunction
function! s:MyPythonSettings()
setlocal autoindent
let python_highlight_all=1
let python_space_errors=1
let python_no_tab_space_error=1
" load pydiction complete file
set complete+=k/home/lowkey/.vim/pydiction
set isk+="i.,("
" Load Pychecfker and Pylint output to a c-window so you can select each error/waring and have
" Vim take you to the line in the file with the problem.
if !exists("g:loaded_pygrep")
function! PythonGrep(tool)
set lazyredraw
" Close any existing cwindows.
cclose
let l:grepformat_save = &grepformat
let l:grepprogram_save = &grepprg
set grepformat&vim
set grepformat&vim
let &grepformat = '%f:%l:%m'
if a:tool == "pylint"
let &grepprg = 'pylint --parseable=y --reports=n'
elseif a:tool == "pychecker"
let &grepprg = 'pychecker --quiet -q'
else
echohl WarningMsg
echo "PythonGrep Error: Unknown Tool"
echohl none
endif
if &readonly == 0 | update | endif
silent! grep! %
let &grepformat = l:grepformat_save
let &grepprg = l:grepprogram_save
let l:mod_total = 0
let l:win_count = 1
" Determine correct window height
windo let l:win_count = l:win_count + 1
if l:win_count - Inaeth, on 10/12/2007, -0/+1@lowkey
Awesome post, Lowkey! I just submitted the article in a humorous attempt to keep the text editor wars alive (like many people on Digg actually care about what kind of text editor that they use, most of them are happy just to tool around with Kate or KWrite), but you definitely upped the ante. Not only was the info you posted informative, but useful as well. Not to mention the URL's that also were posted! - lowkey, on 10/12/2007, -0/+1followup cause of the length limit -----
if l:win_count - lowkey, on 10/12/2007, -0/+1So it wasn't a length limit, it was because digg doesn't allow HTML tags but does not allow greater than and less than symbols. so it broke text.
if l:win_count


What is Digg?
Browsing Digg on your phone just got easier with our enhancements to the