ViとVimでは、通常、.vimrc
ファイル内に保存される、非常に優れたカスタマイズが可能です。プログラマーの典型的な機能は、構文の強調表示、スマートインデントなどです。
。vimrcに隠されている、生産的なプログラミングのためのその他のトリックはありますか?
リファクタリング、自動クラス、および同様の生産性マクロ、特にC#に興味があります。
あなたはそれを求めて :-)
"{{{Auto Commands
" Automatically cd into the directory that the file is in
autocmd BufEnter * execute "chdir ".escape(expand("%:p:h"), ' ')
" Remove any trailing whitespace that is in the file
autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif
" Restore cursor position to where it was before
augroup JumpCursorOnEdit
au!
autocmd BufReadPost *
\ if expand("<afile>:p:h") !=? $TEMP |
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ let JumpCursorOnEdit_foo = line("'\"") |
\ let b:doopenfold = 1 |
\ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) |
\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 |
\ let b:doopenfold = 2 |
\ endif |
\ exe JumpCursorOnEdit_foo |
\ endif |
\ endif
" Need to postpone using "zv" until after reading the modelines.
autocmd BufWinEnter *
\ if exists("b:doopenfold") |
\ exe "normal zv" |
\ if(b:doopenfold > 1) |
\ exe "+".1 |
\ endif |
\ unlet b:doopenfold |
\ endif
augroup END
"}}}
"{{{Misc Settings
" Necesary for lots of cool vim things
set nocompatible
" This shows what you are typing as a command. I love this!
set showcmd
" Folding Stuffs
set foldmethod=marker
" Needed for Syntax Highlighting and stuff
filetype on
filetype plugin on
syntax enable
set grepprg=grep\ -nH\ $*
" Who doesn't like autoindent?
set autoindent
" Spaces are better than a tab character
set expandtab
set smarttab
" Who wants an 8 character tab? Not me!
set shiftwidth=3
set softtabstop=3
" Use english for spellchecking, but don't spellcheck by default
if version >= 700
set spl=en spell
set nospell
endif
" Real men use gcc
"compiler gcc
" Cool tab completion stuff
set wildmenu
set wildmode=list:longest,full
" Enable mouse support in console
set mouse=a
" Got backspace?
set backspace=2
" Line Numbers PWN!
set number
" Ignoring case is a fun trick
set ignorecase
" And so is Artificial Intellegence!
set smartcase
" This is totally awesome - remap jj to escape in insert mode. You'll never type jj anyway, so it's great!
inoremap jj <Esc>
nnoremap JJJJ <Nop>
" Incremental searching is sexy
set incsearch
" Highlight things that we find with the search
set hlsearch
" Since I use linux, I want this
let g:clipbrdDefaultReg = '+'
" When I close a tab, remove the buffer
set nohidden
" Set off the other paren
highlight MatchParen ctermbg=4
" }}}
"{{{Look and Feel
" Favorite Color Scheme
if has("gui_running")
colorscheme inkpot
" Remove Toolbar
set guioptions-=T
"Terminus is AWESOME
set guifont=Terminus\ 9
else
colorscheme metacosm
endif
"Status line gnarliness
set laststatus=2
set statusline=%F%m%r%h%w\ (%{&ff}){%Y}\ [%l,%v][%p%%]
" }}}
"{{{ Functions
"{{{ Open URL in browser
function! Browser ()
let line = getline (".")
let line = matchstr (line, "http[^ ]*")
exec "!konqueror ".line
endfunction
"}}}
"{{{Theme Rotating
let themeindex=0
function! RotateColorTheme()
let y = -1
while y == -1
let colorstring = "inkpot#ron#blue#elflord#evening#koehler#murphy#pablo#desert#torte#"
let x = match( colorstring, "#", g:themeindex )
let y = match( colorstring, "#", x + 1 )
let g:themeindex = x + 1
if y == -1
let g:themeindex = 0
else
let themestring = strpart(colorstring, x + 1, y - x - 1)
return ":colorscheme ".themestring
endif
endwhile
endfunction
" }}}
"{{{ Paste Toggle
let paste_mode = 0 " 0 = normal, 1 = paste
func! Paste_on_off()
if g:paste_mode == 0
set paste
let g:paste_mode = 1
else
set nopaste
let g:paste_mode = 0
endif
return
endfunc
"}}}
"{{{ Todo List Mode
function! TodoListMode()
e ~/.todo.otl
Calendar
wincmd l
set foldlevel=1
tabnew ~/.notes.txt
tabfirst
" or 'norm! zMzr'
endfunction
"}}}
"}}}
"{{{ Mappings
" Open Url on this line with the browser \w
map <Leader>w :call Browser ()<CR>
" Open the Project Plugin <F2>
nnoremap <silent> <F2> :Project<CR>
" Open the Project Plugin
nnoremap <silent> <Leader>pal :Project .vimproject<CR>
" TODO Mode
nnoremap <silent> <Leader>todo :execute TodoListMode()<CR>
" Open the TagList Plugin <F3>
nnoremap <silent> <F3> :Tlist<CR>
" Next Tab
nnoremap <silent> <C-Right> :tabnext<CR>
" Previous Tab
nnoremap <silent> <C-Left> :tabprevious<CR>
" New Tab
nnoremap <silent> <C-t> :tabnew<CR>
" Rotate Color Scheme <F8>
nnoremap <silent> <F8> :execute RotateColorTheme()<CR>
" DOS is for fools.
nnoremap <silent> <F9> :%s/$//g<CR>:%s// /g<CR>
" Paste Mode! Dang! <F10>
nnoremap <silent> <F10> :call Paste_on_off()<CR>
set pastetoggle=<F10>
" Edit vimrc \ev
nnoremap <silent> <Leader>ev :tabnew<CR>:e ~/.vimrc<CR>
" Edit gvimrc \gv
nnoremap <silent> <Leader>gv :tabnew<CR>:e ~/.gvimrc<CR>
" Up and down are more logical with g..
nnoremap <silent> k gk
nnoremap <silent> j gj
inoremap <silent> <Up> <Esc>gka
inoremap <silent> <Down> <Esc>gja
" Good call Benjie (r for i)
nnoremap <silent> <Home> i <Esc>r
nnoremap <silent> <End> a <Esc>r
" Create Blank Newlines and stay in Normal mode
nnoremap <silent> zj o<Esc>
nnoremap <silent> zk O<Esc>
" Space will toggle folds!
nnoremap <space> za
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
map N Nzz
map n nzz
" Testing
set completeopt=longest,menuone,preview
inoremap <expr> <cr> pumvisible() ? "\<c-y>" : "\<c-g>u\<cr>"
inoremap <expr> <c-n> pumvisible() ? "\<lt>c-n>" : "\<lt>c-n>\<lt>c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<lt>cr>"
inoremap <expr> <m-;> pumvisible() ? "\<lt>c-n>" : "\<lt>c-x>\<lt>c-o>\<lt>c-n>\<lt>c-p>\<lt>c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<lt>cr>"
" Swap ; and : Convenient.
nnoremap ; :
nnoremap : ;
" Fix email paragraphs
nnoremap <leader>par :%s/^>$//<CR>
"ly$O#{{{ "lpjjj_%A#}}}jjzajj
"}}}
"{{{Taglist configuration
let Tlist_Use_Right_Window = 1
let Tlist_Enable_Fold_Column = 0
let Tlist_Exit_OnlyWindow = 1
let Tlist_Use_SingleClick = 1
let Tlist_Inc_Winwidth = 0
"}}}
let g:rct_completion_use_fri = 1
"let g:Tex_DefaultTargetFormat = "pdf"
let g:Tex_ViewRule_pdf = "kpdf"
filetype plugin indent on
syntax on
これは私の.vimrcファイルにはありませんが、昨日]p
コマンドについて学びました。これは、p
と同じようにバッファーの内容を貼り付けますが、カーソルが置かれている行に一致するようにインデントを自動的に調整します!これは、コードを移動するのに最適です。
以下を使用して、すべての一時ファイルとバックアップファイルを1か所に保管します。
set backup
set backupdir=~/.vim/backup
set directory=~/.vim/tmp
いたるところに散らかった作業ディレクトリを保存します。
これらのディレクトリを最初に作成する必要があります。vimはnotを作成します。
上記の投稿者(つまり、Frew)には次の行がありました。
「ファイルがあるディレクトリに自動的にcdします。」
autocmd BufEnter * execute "chdir ".escape(expand("%:p:h"), ' ')
同じことを組み込みの設定で実現できるようになるまで、私は自分でそのようなことをしていました。
set autochdir
似たようなことが何度か起こったと思います。 Vimにはさまざまな組み込みの設定とオプションがあるため、組み込みの方法をドキュメントで検索するよりも、自分で簡単にロールオーバーすることができます。
私の最新の追加は、現在の行の強調表示
set cul # highlight current line
hi CursorLine term=none cterm=none ctermbg=3 # adjust color
Update 2012:私は今、本当に欠けているものの、古いstatuslineスクリプトを置き換える vim-powerline をチェックアウトすることを本当にお勧めします私が欠場するいくつかの機能。
my vimrc のstatuslineのものは、たぶんロットのなかで最も興味深く/有用だったと思います(著者vimrc here および対応するブログ投稿 ここ )。
スクリーンショット:
ステータスラインhttp://img34.imageshack.us/img34/849/statusline.png
コード:
"recalculate the trailing whitespace warning when idle, and after saving
autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning
"return '[\s]' if trailing white space is detected
"return '' otherwise
function! StatuslineTrailingSpaceWarning()
if !exists("b:statusline_trailing_space_warning")
if !&modifiable
let b:statusline_trailing_space_warning = ''
return b:statusline_trailing_space_warning
endif
if search('\s\+$', 'nw') != 0
let b:statusline_trailing_space_warning = '[\s]'
else
let b:statusline_trailing_space_warning = ''
endif
endif
return b:statusline_trailing_space_warning
endfunction
"return the syntax highlight group under the cursor ''
function! StatuslineCurrentHighlight()
let name = synIDattr(synID(line('.'),col('.'),1),'name')
if name == ''
return ''
else
return '[' . name . ']'
endif
endfunction
"recalculate the tab warning flag when idle and after writing
autocmd cursorhold,bufwritepost * unlet! b:statusline_tab_warning
"return '[&et]' if &et is set wrong
"return '[mixed-indenting]' if spaces and tabs are used to indent
"return an empty string if everything is fine
function! StatuslineTabWarning()
if !exists("b:statusline_tab_warning")
let b:statusline_tab_warning = ''
if !&modifiable
return b:statusline_tab_warning
endif
let tabs = search('^\t', 'nw') != 0
"find spaces that arent used as alignment in the first indent column
let spaces = search('^ \{' . &ts . ',}[^\t]', 'nw') != 0
if tabs && spaces
let b:statusline_tab_warning = '[mixed-indenting]'
elseif (spaces && !&et) || (tabs && &et)
let b:statusline_tab_warning = '[&et]'
endif
endif
return b:statusline_tab_warning
endfunction
"recalculate the long line warning when idle and after saving
autocmd cursorhold,bufwritepost * unlet! b:statusline_long_line_warning
"return a warning for "long lines" where "long" is either &textwidth or 80 (if
"no &textwidth is set)
"
"return '' if no long lines
"return '[#x,my,$z] if long lines are found, were x is the number of long
"lines, y is the median length of the long lines and z is the length of the
"longest line
function! StatuslineLongLineWarning()
if !exists("b:statusline_long_line_warning")
if !&modifiable
let b:statusline_long_line_warning = ''
return b:statusline_long_line_warning
endif
let long_line_lens = s:LongLines()
if len(long_line_lens) > 0
let b:statusline_long_line_warning = "[" .
\ '#' . len(long_line_lens) . "," .
\ 'm' . s:Median(long_line_lens) . "," .
\ '$' . max(long_line_lens) . "]"
else
let b:statusline_long_line_warning = ""
endif
endif
return b:statusline_long_line_warning
endfunction
"return a list containing the lengths of the long lines in this buffer
function! s:LongLines()
let threshold = (&tw ? &tw : 80)
let spaces = repeat(" ", &ts)
let long_line_lens = []
let i = 1
while i <= line("$")
let len = strlen(substitute(getline(i), '\t', spaces, 'g'))
if len > threshold
call add(long_line_lens, len)
endif
let i += 1
endwhile
return long_line_lens
endfunction
"find the median of the given array of numbers
function! s:Median(nums)
let nums = sort(a:nums)
let l = len(nums)
if l % 2 == 1
let i = (l-1) / 2
return nums[i]
else
return (nums[l/2] + nums[(l/2)-1]) / 2
endif
endfunction
"statusline setup
set statusline=%f "tail of the filename
"display a warning if fileformat isnt unix
set statusline+=%#warningmsg#
set statusline+=%{&ff!='unix'?'['.&ff.']':''}
set statusline+=%*
"display a warning if file encoding isnt utf-8
set statusline+=%#warningmsg#
set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
set statusline+=%*
set statusline+=%h "help file flag
set statusline+=%y "filetype
set statusline+=%r "read only flag
set statusline+=%m "modified flag
"display a warning if &et is wrong, or we have mixed-indenting
set statusline+=%#error#
set statusline+=%{StatuslineTabWarning()}
set statusline+=%*
set statusline+=%{StatuslineTrailingSpaceWarning()}
set statusline+=%{StatuslineLongLineWarning()}
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
"display a warning if &paste is set
set statusline+=%#error#
set statusline+=%{&paste?'[paste]':''}
set statusline+=%*
set statusline+=%= "left/right separator
function! SlSpace()
if exists("*GetSpaceMovement")
return "[" . GetSpaceMovement() . "]"
else
return ""
endif
endfunc
set statusline+=%{SlSpace()}
set statusline+=%{StatuslineCurrentHighlight()}\ \ "current highlight
set statusline+=%c, "cursor column
set statusline+=%l/%L "cursor line/total lines
set statusline+=\ %P "percent through file
set laststatus=2
とりわけ、通常の標準ファイル情報をステータス行で通知しますが、:set paste、混合インデント、末尾の空白などの警告などの追加情報も含まれます。コードの書式設定について特にアナルを使用する場合は非常に便利です。
さらに、スクリーンショットに示すように、 syntastic と組み合わせることで、構文エラーを強調表示できます(選択した言語に関連する構文チェッカーがバンドルされていると仮定します)。
私のミニバージョン:
syntax on
set background=dark
set shiftwidth=2
set tabstop=2
if has("autocmd")
filetype plugin indent on
endif
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
set hidden " Hide buffers when they are abandoned
さまざまな場所から収集されたビッグバージョン:
syntax on
set background=dark
set ruler " show the line number on the bar
set more " use more Prompt
set autoread " watch for file changes
set number " line numbers
set hidden
set noautowrite " don't automagically write on :next
set lazyredraw " don't redraw when don't have to
set showmode
set showcmd
set nocompatible " vim, not vi
set autoindent smartindent " auto/smart indent
set smarttab " tab and backspace are smart
set tabstop=2 " 6 spaces
set shiftwidth=2
set scrolloff=5 " keep at least 5 lines above/below
set sidescrolloff=5 " keep at least 5 lines left/right
set history=200
set backspace=indent,eol,start
set linebreak
set cmdheight=2 " command line two lines high
set undolevels=1000 " 1000 undos
set updatecount=100 " switch every 100 chars
set complete=.,w,b,u,U,t,i,d " do lots of scanning on tab completion
set ttyfast " we have a fast terminal
set noerrorbells " No error bells please
set Shell=bash
set fileformats=unix
set ff=unix
filetype on " Enable filetype detection
filetype indent on " Enable filetype-specific indenting
filetype plugin on " Enable filetype-specific plugins
set wildmode=longest:full
set wildmenu " menu has tab completion
let maplocalleader=',' " all my macros start with ,
set laststatus=2
" searching
set incsearch " incremental search
set ignorecase " search ignoring case
set hlsearch " highlight the search
set showmatch " show matching bracket
set diffopt=filler,iwhite " ignore all whitespace and sync
" backup
set backup
set backupdir=~/.vim_backup
set viminfo=%100,'100,/100,h,\"500,:100,n~/.viminfo
"set viminfo='100,f1
" spelling
if v:version >= 700
" Enable spell check for text files
autocmd BufNewFile,BufRead *.txt setlocal spell spelllang=en
endif
" mappings
" toggle list mode
nmap <LocalLeader>tl :set list!<cr>
" toggle paste mode
nmap <LocalLeader>pp :set paste!<cr>
時には、最も単純なものが最も価値があります。完全に不可欠な私の.vimrcの2行:
nore; : nore、;
その他設定:
迷惑なエラーベルをオフにします。
set noerrorbells
set visualbell
set t_vb=
ラップされた行でカーソルを期待どおりに移動します。
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
ディレクトリが見つかるまでctags
"tags"ファイルを検索します。
set tags=tags;/
Python構文でSConsファイルを表示します。
autocmd BufReadPre,BufNewFile SConstruct set filetype=python
autocmd BufReadPre,BufNewFile SConscript set filetype=python
私は世界で最も先進的なヴィマーではありませんが、ここに私が取り上げたいくつかがあります
function! Mosh_Tab_Or_Complete()
if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w'
return "\<C-N>"
else
return "\<Tab>"
endfunction
inoremap <Tab> <C-R>=Mosh_Tab_Or_Complete()<CR>
Wordをそこに配置するか、実際のタブ(4つのスペース)を配置するかをタブオートコンプリートで判断します。
map cc :.,$s/^ *//<CR>
ここからファイルの最後まで開いている空白をすべて削除します。なんらかの理由で、これは非常に便利です。
set nu!
set nobackup
行番号を表示し、それらの迷惑なバックアップファイルを作成しないでください。とにかく古いバックアップから何かを復元したことはありません。
imap ii <C-[>
挿入中にiを2回押して、コマンドモードに移動します。私は2 iが連続しているWordや変数に出くわしたことがないので、この方法で指をホーム行から離したり、複数のキーを押して前後に切り替える必要はありません。
Readline-esque(emacs)キーバインドを使用した、vimrcのコメントが多かった:
if version >= 700
"------ Meta ------"
" clear all autocommands! (this comment must be on its own line)
autocmd!
set nocompatible " break away from old vi compatibility
set fileformats=unix,dos,mac " support all three newline formats
set viminfo= " don't use or save viminfo files
"------ Console UI & Text display ------"
set cmdheight=1 " explicitly set the height of the command line
set showcmd " Show (partial) command in status line.
set number " yay line numbers
set ruler " show current position at bottom
set noerrorbells " don't whine
set visualbell t_vb= " and don't make faces
set lazyredraw " don't redraw while in macros
set scrolloff=5 " keep at least 5 lines around the cursor
set wrap " soft wrap long lines
set list " show invisible characters
set listchars=tab:>·,trail:· " but only show tabs and trailing whitespace
set report=0 " report back on all changes
set shortmess=ATI " shorten messages and don't show intro
set wildmenu " turn on wild menu :e <Tab>
set wildmode=list:longest " set wildmenu to list choice
if has('syntax')
syntax on
" Remember that rxvt-unicode has 88 colors by default; enable this only if
" you are using the 256-color patch
if &term == 'rxvt-unicode'
set t_Co=256
endif
if &t_Co == 256
colorscheme xoria256
else
colorscheme peachpuff
endif
endif
"------ Text editing and searching behavior ------"
set nohlsearch " turn off highlighting for searched expressions
set incsearch " highlight as we search however
set matchtime=5 " blink matching chars for .x seconds
set mouse=a " try to use a mouse in the console (wimp!)
set ignorecase " set case insensitivity
set smartcase " unless there's a capital letter
set completeopt=menu,longest,preview " more autocomplete <Ctrl>-P options
set nostartofline " leave my cursor position alone!
set backspace=2 " equiv to :set backspace=indent,eol,start
set textwidth=80 " we like 80 columns
set showmatch " show matching brackets
set formatoptions=tcrql " t - autowrap to textwidth
" c - autowrap comments to textwidth
" r - autoinsert comment leader with <Enter>
" q - allow formatting of comments with :gq
" l - don't format already long lines
"------ Indents and tabs ------"
set autoindent " set the cursor at same indent as line above
set smartindent " try to be smart about indenting (C-style)
set expandtab " expand <Tab>s with spaces; death to tabs!
set shiftwidth=4 " spaces for each step of (auto)indent
set softtabstop=4 " set virtual tab stop (compat for 8-wide tabs)
set tabstop=8 " for proper display of files with tabs
set shiftround " always round indents to multiple of shiftwidth
set copyindent " use existing indents for new indents
set preserveindent " save as much indent structure as possible
filetype plugin indent on " load filetype plugins and indent settings
"------ Key bindings ------"
" Remap broken meta-keys that send ^[
for n in range(97,122) " ASCII a-z
let c = nr2char(n)
exec "set <M-". c .">=\e". c
exec "map \e". c ." <M-". c .">"
exec "map! \e". c ." <M-". c .">"
endfor
""" Emacs keybindings
" first move the window command because we'll be taking it over
noremap <C-x> <C-w>
" Movement left/right
noremap! <C-b> <Left>
noremap! <C-f> <Right>
" Word left/right
noremap <M-b> b
noremap! <M-b> <C-o>b
noremap <M-f> w
noremap! <M-f> <C-o>w
" line start/end
noremap <C-a> ^
noremap! <C-a> <Esc>I
noremap <C-e> $
noremap! <C-e> <Esc>A
" Rubout Word / line and enter insert mode
noremap <C-w> i<C-w>
noremap <C-u> i<C-u>
" Forward delete char / Word / line and enter insert mode
noremap! <C-d> <C-o>x
noremap <M-d> dw
noremap! <M-d> <C-o>dw
noremap <C-k> Da
noremap! <C-k> <C-o>D
" Undo / Redo and enter normal mode
noremap <C-_> u
noremap! <C-_> <C-o>u<Esc><Right>
noremap! <C-r> <C-o><C-r><Esc>
" Remap <C-space> to Word completion
noremap! <Nul> <C-n>
" OS X paste (pretty poor implementation)
if has('mac')
noremap √ :r!pbpaste<CR>
noremap! √ <Esc>√
endif
""" screen.vim REPL: http://github.com/ervandew/vimfiles
" send paragraph to parallel process
vmap <C-c><C-c> :ScreenSend<CR>
nmap <C-c><C-c> mCvip<C-c><C-c>`C
imap <C-c><C-c> <Esc><C-c><C-c><Right>
" set Shell region height
let g:ScreenShellHeight = 12
"------ Filetypes ------"
" Vimscript
autocmd FileType vim setlocal expandtab shiftwidth=4 tabstop=8 softtabstop=4
" Shell
autocmd FileType sh setlocal expandtab shiftwidth=4 tabstop=8 softtabstop=4
" LISP
autocmd Filetype LISP,scheme setlocal equalprg=~/.vim/bin/lispindent.LISP expandtab shiftwidth=2 tabstop=8 softtabstop=2
" Ruby
autocmd FileType Ruby setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
" PHP
autocmd FileType php setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
" X?HTML & XML
autocmd FileType html,xhtml,xml setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
" CSS
autocmd FileType css setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
" JavaScript
" autocmd BufRead,BufNewFile *.json setfiletype javascript
autocmd FileType javascript setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
let javascript_enable_domhtmlcss=1
"------ END VIM-500 ------"
endif " version >= 500
syntax on
set cindent
set ts=4
set sw=4
set backspace=2
set laststatus=2
set nohlsearch
set modeline
set modelines=3
set ai
map Q gq
set vb t_vb=
set nowrap
set ss=5
set is
set scs
set ru
map <F2> <Esc>:w<CR>
map! <F2> <Esc>:w<CR>
map <F10> <Esc>:qa<CR>
map! <F10> <Esc>:qa<CR>
map <F9> <Esc>:wqa<CR>
map! <F9> <Esc>:wqa<CR>
inoremap <s-up> <Esc><c-w>W<Ins>
inoremap <s-down> <Esc><c-w>w<Ins>
nnoremap <s-up> <c-w>W
nnoremap <s-down> <c-w>w
" Fancy middle-line <CR>
inoremap <C-CR> <Esc>o
nnoremap <C-CR> o
" This is the way I like my quotation marks and various braces
inoremap '' ''<Left>
inoremap "" ""<Left>
inoremap () ()<Left>
inoremap <> <><Left>
inoremap {} {}<Left>
inoremap [] []<Left>
inoremap () ()<Left>
" Quickly set comma or semicolon at the end of the string
inoremap ,, <End>,
inoremap ;; <End>;
au FileType python inoremap :: <End>:
au FileType Perl,python set foldlevel=0
au FileType Perl,python set foldcolumn=4
au FileType Perl,python set fen
au FileType Perl set fdm=syntax
au FileType python set fdm=indent
au FileType Perl,python set fdn=4
au FileType Perl,python set fml=10
au FileType Perl,python set fdo=block,hor,mark,percent,quickfix,search,tag,undo,search
au FileType Perl,python abbr sefl self
au FileType Perl abbr sjoft shift
au FileType Perl abbr DUmper Dumper
function! ToggleNumberRow()
if !exists("g:NumberRow") || 0 == g:NumberRow
let g:NumberRow = 1
call ReverseNumberRow()
else
let g:NumberRow = 0
call NormalizeNumberRow()
endif
endfunction
" Reverse the number row characters
function! ReverseNumberRow()
" map each number to its shift-key character
inoremap 1 !
inoremap 2 @
inoremap 3 #
inoremap 4 $
inoremap 5 %
inoremap 6 ^
inoremap 7 &
inoremap 8 *
inoremap 9 (
inoremap 0 )
inoremap - _
inoremap 90 ()<Left>
" and then the opposite
inoremap ! 1
inoremap @ 2
inoremap # 3
inoremap $ 4
inoremap % 5
inoremap ^ 6
inoremap & 7
inoremap * 8
inoremap ( 9
inoremap ) 0
inoremap _ -
endfunction
" DO the opposite to ReverseNumberRow -- give everything back
function! NormalizeNumberRow()
iunmap 1
iunmap 2
iunmap 3
iunmap 4
iunmap 5
iunmap 6
iunmap 7
iunmap 8
iunmap 9
iunmap 0
iunmap -
"------
iunmap !
iunmap @
iunmap #
iunmap $
iunmap %
iunmap ^
iunmap &
iunmap *
iunmap (
iunmap )
iunmap _
inoremap () ()<Left>
endfunction
"call ToggleNumberRow()
nnoremap <M-n> :call ToggleNumberRow()<CR>
" Add use <CWORD> at the top of the file
function! UseWord(Word)
let spec_cases = {'Dumper': 'Data::Dumper'}
let my_Word = a:Word
if has_key(spec_cases, my_Word)
let my_Word = spec_cases[my_Word]
endif
let was_used = search("^use.*" . my_Word, "bw")
if was_used > 0
echo "Used already"
return 0
endif
let last_use = search("^use", "bW")
if 0 == last_use
last_use = search("^package", "bW")
if 0 == last_use
last_use = 1
endif
endif
let use_string = "use " . my_Word . ";"
let res = append(last_use, use_string)
return 1
endfunction
function! UseCWord()
let cline = line(".")
let ccol = col(".")
let ch = UseWord(expand("<cword>"))
normal mu
call cursor(cline + ch, ccol)
endfunction
function! GetWords(pattern)
let cline = line(".")
let ccol = col(".")
call cursor(1,1)
let temp_dict = {}
let cpos = searchpos(a:pattern)
while cpos[0] != 0
let temp_dict[expand("<cword>")] = 1
let cpos = searchpos(a:pattern, 'W')
endwhile
call cursor(cline, ccol)
return keys(temp_dict)
endfunction
" Append the list of words, that match the pattern after cursor
function! AppendWordsLike(pattern)
let Word_list = sort(GetWords(a:pattern))
call append(line("."), Word_list)
endfunction
nnoremap <F7> :call UseCWord()<CR>
" Useful to mark some code lines as debug statements
function! MarkDebug()
let cline = line(".")
let ctext = getline(cline)
call setline(cline, ctext . "##_DEBUG_")
endfunction
" Easily remove debug statements
function! RemoveDebug()
%g/#_DEBUG_/d
endfunction
au FileType Perl,python inoremap <M-d> <Esc>:call MarkDebug()<CR><Ins>
au FileType Perl,python inoremap <F6> <Esc>:call RemoveDebug()<CR><Ins>
au FileType Perl,python nnoremap <F6> :call RemoveDebug()<CR>
" end Perl settings
nnoremap <silent> <F8> :TlistToggle<CR>
inoremap <silent> <F8> <Esc>:TlistToggle<CR><Esc>
function! AlwaysCD()
if bufname("") !~ "^scp://" && bufname("") !~ "^sftp://" && bufname("") !~ "^ftp://"
lcd %:p:h
endif
endfunction
autocmd BufEnter * call AlwaysCD()
function! DeleteRedundantSpaces()
let cline = line(".")
let ccol = col(".")
silent! %s/\s\+$//g
call cursor(cline, ccol)
endfunction
au BufWrite * call DeleteRedundantSpaces()
set nobackup
set nowritebackup
set cul
colorscheme evening
autocmd FileType python set formatoptions=wcrq2l
autocmd FileType python set inc="^\s*from"
autocmd FileType python so /usr/share/vim/vim72/indent/python.vim
autocmd FileType c set si
autocmd FileType mail set noai
autocmd FileType mail set ts=3
autocmd FileType mail set tw=78
autocmd FileType mail set shiftwidth=3
autocmd FileType mail set expandtab
autocmd FileType xslt set ts=4
autocmd FileType xslt set shiftwidth=4
autocmd FileType txt set ts=3
autocmd FileType txt set tw=78
autocmd FileType txt set expandtab
" Move cursor together with the screen
noremap <c-j> j<c-e>
noremap <c-k> k<c-y>
" Better Marks
nnoremap ' `
一般的なタイプミスの修正により、驚くほどの時間が節約されました。
:command WQ wq
:command Wq wq
:command W w
:command Q q
iab anf and
iab adn and
iab ans and
iab teh the
iab thre there
3200個の.vimrc行のうち、どれだけが私の風変わりなニーズのためのものであるかはわかりませんでした。しかし、それがVimがとても便利な理由かもしれません...
iab AlP ABCDEFGHIJKLMNOPQRSTUVWXYZ
iab MoN January February March April May June July August September October November December
iab MoO Jan Feb Mar Apr May Jun Jul Aug Sep Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
iab NuM 12345678901234567890123456789012345678901234567890123456789012345678901234567890
iab RuL ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
" Highlight every other line
map ,<Tab> :set hls<CR>/\\n.*\\n/<CR>
" This is for working across multiple xterms and/or gvims
" Transfer/read and write one block of text between vim sessions (capture whole line):
" Write
nmap ;w :. w! ~/.vimxfer<CR>
" Read
nmap ;r :r ~/.vimxfer<CR>
" Append
nmap ;a :. w! >>~/.vimxfer<CR>
私の242行の.vimrc
はそれほど興味深いものではありませんが、誰も言及していないので、デフォルトのマッピング以外にワークフローを強化した2つの最も重要なマッピングを共有しなければならないと感じました:
map <C-j> :bprev<CR>
map <C-k> :bnext<CR>
set hidden " this will go along
真剣に、バッファの切り替えはthe非常に頻繁に行うことです。確かにWindowsですが、すべてが画面にうまく収まるわけではありません。
エラー(クイックフィックスを参照)およびgrepの結果をすばやく参照するための同様のマップセット:
map <C-n> :cn<CR>
map <C-m> :cp<CR>
シンプルで簡単、効率的。
set nobackup
set nocp
set tabstop=4
set shiftwidth=4
set et
set ignorecase
set ai
set ruler
set showcmd
set incsearch
set dir=$temp " Make swap live in the %TEMP% directory
syn on
" Load the color scheme
colo inkpot
Vim内からcscopeを使用します(複数のバッファーを最大限に活用しています)。 control-Kを使用して、ほとんどのコマンド(思い出すとctagsから盗まれました)を開始します。また、すでに.cscope.outファイルを生成しています。
if has( "cscope")
set cscopeprg=/usr/local/bin/cscope
set cscopetagorder=0
set cscopetag
set cscopepathcomp=3
set nocscopeverbose
cs add .cscope.out
set csverb
"
" cscope find
"
" 0 or s: Find this C symbol
" 1 or d: Find this definition
" 2 or g: Find functions called by this function
" 3 or c: Find functions calling this function
" 4 or t: Find assignments to
" 6 or e: Find this egrep pattern
" 7 or f: Find this file
" 8 or i: Find files #including this file
"
map ^Ks :cs find 0 <C-R>=expand("<cword>")<CR><CR>
map ^Kd :cs find 1 <C-R>=expand("<cword>")<CR><CR>
map ^Kg :cs find 2 <C-R>=expand("<cword>")<CR><CR>
map ^Kc :cs find 3 <C-R>=expand("<cword>")<CR><CR>
map ^Kt :cs find 4 <C-R>=expand("<cword>")<CR><CR>
map ^Ke :cs find 6 <C-R>=expand("<cword>")<CR><CR>
map ^Kf :cs find 7 <C-R>=expand("<cfile>")<CR><CR>
map ^Ki :cs find 8 <C-R>=expand("%")<CR><CR>
エンディフ
Vimrcファイルはgithubに保存します。ここで見つけることができます:
私はOS Xにいるので、これらのいくつかは他のプラットフォームでより良いデフォルトを持っているかもしれませんが、それにもかかわらず:
syntax on
set tabstop=4
set expandtab
set shiftwidth=4
map = }{!}fmt^M}
map + }{!}fmt -p '> '^M}
set showmatch
=は、通常の段落を再フォーマットするためのものです。 +は、引用メールの段落を再フォーマットするためのものです。 showmatchは、閉じかっこまたはかっこを入力したときに、一致するかっこ/かっこをフラッシュするためのものです。
ディレクトリツリーで最初に使用可能な「タグ」ファイルを使用します。
:set tags=tags;/
左と右はバッファを切り替えるためのもので、カーソルを移動するためのものではありません。
map <right> <ESC>:bn<RETURN>
map <left> <ESC>:bp<RETURN>
キーを1回押すだけで検索の強調表示を無効にします。
map - :nohls<cr>
これをvimrcに入れてください:
imap <C-l> <Space>=><Space>
再びハッシュロケットを入力することを考えないでください。はい、Ruby 1.9では不要であることがわかります。しかし、気にしないでください。
私の完全なvimrcは here です。
set tabstop=4 softtabstop=4 shiftwidth=4 expandtab autoindent cindent
set encoding=utf-8 fileencoding=utf-8
set nobackup nowritebackup noswapfile autoread
set number
set hlsearch incsearch ignorecase smartcase
if has("gui_running")
set lines=35 columns=140
colorscheme ir_black
else
colorscheme darkblue
endif
" bash like auto-completion
set wildmenu
set wildmode=list:longest
inoremap <C-j> <Esc>
" for lusty Explorer
noremap glr \lr
noremap glf \lf
noremap glb \lb
" use ctrl-h/j/k/l to switch between splits
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
" Nerd tree stuff
let NERDTreeIgnore = ['\.pyc$', '\.pyo$']
noremap gn :NERDTree<Cr>
" cd to the current file's directory
noremap gc :lcd %:h<Cr>
私の.vimrcには(他の、より有用なものの中でも)次の行が含まれています。
set statusline=%2*%n\|%<%*%-.40F%2*\|\ %2*%M\ %3*%=%1*\ %1*%2.6l%2*x%1*%1.9(%c%V%)%2*[%1*%P%2*]%1*%2B
高校の決勝戦で学んでいる間、私は退屈しました。
my .vimrc には実際にはあまりありません(たとえ850行あるとしても)。ほとんどの設定と、プラグインに抽出するのが面倒だったいくつかの一般的でシンプルなマッピング。
「auto-classes」で「テンプレートファイル」を意味する場合、この同じサイトで template-expander plugin -を使用しています。C&C++で定義したftpluginsが見つかります。編集、一部はC#に適合していると思います。
リファクタリングの側面に関しては、このテーマに特化したヒントがあります http://vim.wikia.com ; IIRCサンプルコードはC#用です。 リファクタリングプラグイン にインスパイアされ、まだ多くの作業が必要です(実際にリファクタリングする必要があります)。
Vimメーリングリストのアーカイブ、特にvimを効果的なIDEとして使用することに関するテーマをご覧ください。 :make、tags、...を見ることを忘れないでください...
HTH、
さて、あなたは configs を自分で清掃する必要があります。楽しむ。ほとんどは、マッピングやランダムな構文関連のもの、折り畳み設定といくつかのプラグイン設定、texコンパイルパーサーなどを含む、私の希望する設定です。
ところで、私が非常に便利だと思ったのは「カーソルの下のWordを強調表示する」です。
highlight flicker cterm=bold ctermfg=white
au CursorMoved <buffer> exe 'match flicker /\V\<'.escape(expand('<cword>'), '/').'\>/'
cterm
は使用しないため、termfg
とgvim
のみが使用されることに注意してください。それをgvim
で動作させたい場合は、それぞれgui
とguifg
に置き換えてください。
my .vimrc を可能な限り一般的に有用なものにしようとしました。
そこにある便利なトリックは、安全に編集するための.gpgファイルのハンドラーです:
au BufNewFile,BufReadPre *.gpg :set secure vimi= noswap noback nowriteback hist=0 binary
au BufReadPost *.gpg :%!gpg -d 2>/dev/null
au BufWritePre *.gpg :%!gpg -e -r '[email protected]' 2>/dev/null
au BufWritePost *.gpg u
1)ステータスライン(ファイル名、ASCII値(10進数)、16進数値、標準行、列、%)が好きです:
set statusline=%t%h%m%r%=[%b\ 0x%02B]\ \ \ %l,%c%V\ %P
" Always show a status line
set laststatus=2
"make the command line 1 line high
set cmdheight=1
2)分割ウィンドウのマッピングも好きです。
" <space> switches to the next window (give it a second)
" <space>n switches to the next window
" <space><space> switches to the next window and maximizes it
" <space>= Equalizes the size of all windows
" + Increases the size of the current window
" - Decreases the size of the current window
:map <space> <c-W>w
:map <space>n <c-W>w
:map <space><space> <c-W>w<c-W>_
:map <space>= <c-W>=
if bufwinnr(1)
map + <c-W>+
map - <c-W>-
endif
これは私の.vimrcではありませんが、関連しています。
.bashrcにこの行を追加しますalias :q=exit
驚くほど、これをどれだけ使ったか、時には気づかないこともあります!
私なしでは生きていけない行であり、一般的に.vimrc
に最初に現れる行:
" prevent switch to Replece mode if <Insert> pressed in insert mode
imap <Insert> <Nop>
これなしでは生きていけないもう1つのビットは、PgDown/PgUpを押すときに現在の行を保持することです。
map <silent> <PageUp> 1000<C-U>
map <silent> <PageDown> 1000<C-D>
imap <silent> <PageUp> <C-O>1000<C-U>
imap <silent> <PageDown> <C-O>1000<C-D>
set nostartofline
迷惑な一致する括弧の強調表示を無効にします。
set noshowmatch
let loaded_matchparen = 1
巨大な(> 4MB)ファイルを編集するときは、構文の強調表示を無効にします。
au BufReadPost * if getfsize(bufname("%")) > 4*1024*1024 |
\ set syntax= |
\ endif
そして最後に 私の単純なインライン計算機 :
function CalcX(line_num)
let l = getline(a:line_num)
let expr = substitute( l, " *=.*$","","" )
exec ":let g:tmp_calcx = ".expr
call setline(a:line_num, expr." = ".g:tmp_calcx)
endfunction
:map <silent> <F11> :call CalcX(".")<CR>
私の.vimrcは Githubで利用可能 です。たくさんの小さな調整と便利なバインディングがあります:)
.vimrc
には何が含まれていますか?
ngn@macavity:~$ cat .vimrc
" This file intentionally left blank
実際の設定ファイルは~/.vim/ :)
の下にあります
そして、そこにあるもののほとんどは、他の人の努力に寄生しており、vim.org
から私の編集の利点に露骨に適応しました。
.vimrcと.bashrcに加えて、.vimフォルダー全体(すべてのプラグインを含む)は、 http://code.google.com/p/pal-nix/ で入手できます。
クイックレビュー用の.vimrcを次に示します。
" .vimrc
"
" $Author$
" $Date$
" $Revision$
" * Initial Configuration * {{{1 "
" change directory on open file, buffer switch etc. {{{2
set autochdir
" turn on filetype detection and indentation {{{2
filetype indent plugin on
" set tags file to search in parent directories with tags; {{{2
set tags=tags;
" reload vimrc on update {{{2
autocmd BufWritePost .vimrc source %
" set folds to look for markers {{{2
:set foldmethod=marker
" automatically save view and reload folds {{{2
"au BufWinLeave * mkview
"au BufWinEnter * silent loadview
" behave like windows {{{2
"source $VIMRUNTIME/mswin.vim " can't use if on (use with gvim only)
"behave mswin
" load dictionary files for complete suggestion with Ctrl-n {{{2
set complete+=k
autocmd FileType * exec('set dictionary+=~/.vim/dict/' . &filetype)
" * User Interface * {{{1 "
" turn on coloring {{{2
if has('syntax')
syntax on
endif
" gvim color scheme of choice {{{2
if has('gui')
so $VIMRUNTIME/colors/desert.vim
endif
" turn off annoying bell {{{2
set vb
" set the directory for swp files {{{2
if(isdirectory(expand("$VIMRUNTIME/swp")))
set dir=$VIMRUNTIME/swp
endif
" have fifty lines of cmdline (etc) history {{{2
set history=50
" have cmdline completion (for filenames, help topics, option names) {{{2
" first list the available options and complete the longest common part, then
" have further s cycle through the possibilities:
set wildmode=list:longest,full
" use "[RO]" for "[readonly]" to save space in the message line: {{{2
set shortmess+=r
" display current mode and partially typed commands in status line {{{2
set showmode
set showcmd
" Text Formatting -- General {{{2
set nocompatible "prevents vim from emulating vi's original bugs
set backspace=2 "make backspace work normal (indent, eol, start)
set autoindent
set smartindent "makes vim smartly guess indent level
set tabstop=2 "sets up 2 space tabs
set shiftwidth=2 "tells vim to use 2 spaces when text is indented
set smarttab "uses shiftwidth for inserting s
set expandtab "insert spaces instead of
set softtabstop=2 "makes vim see multiple space characters as tabstops
set showmatch "causes cursor to jump to bracket match
set mat=5 "how many tenths of a second to blink matches
set guioptions-=T "removes toolbar from gvim
set ruler "ensures each window contains a status line
set incsearch "vim will search for text as you type
set hlsearch "highlight search terms
set hl=l:Visual "use Visual mode's highlighting scheme --much better
set ignorecase "ignore case in searches --faster this way
set virtualedit=all "allows the cursor to stray beyond defined text
set number "show line numbers in left margin
set path=$PWD/** "recursively set the path of the project
"get more information from the status line
set statusline=[%n]\ %<%.99f\ %h%w%m%r%{exists('*CapsLockStatusline')?CapsLockStatusline():''}%y%=%-16(\ %l,%c-%v\ %)%P
set laststatus=2 "keep status line showing
set cursorline "highlight current line
highlight CursorLine guibg=lightblue guifg=white ctermbg=blue ctermfg=white
"set spell "spell check
set spellsuggest=3 "suggest better spelling
set spelllang=en "set language
set encoding=utf-8 "set character encoding
" * Macros * {{{1 "
" Function keys {{{2
" Don't you always find yourself hitting instead of ? {{{3
inoremap
noremap
" turn off syntax highlighting {{{3
nnoremap :nohlsearch
inoremap :nohlsearcha
" NERD Tree Explorer {{{3
nnoremap :NERDTreeToggle
" open tag list {{{3
nnoremap :TlistToggle
" Spell check {{{3
nnoremap :set spell
" No spell check {{{3
nnoremap :set nospell
" refactor curly braces on keyword line {{{3
map :%s/) \?\n^\s*{/) {/g
" useful mappings to paste and reformat/reindent {{{2
nnoremap P P'[v']=
nnoremap p P'[v']=
" * Scripts * {{{1 "
:au Filetype html,xml,xsl source ~/.vim/scripts/closetag.vim
" Modeline {{{1
" vim:set fdm=marker sw=4 ts=4:
リターン、バックスペース、スペースバー、ハイフンキーは便利なものにバインドされていないため、ドキュメント内をより便利にナビゲートできるようにマッピングします。
" Page down, page up, scroll down, scroll up
noremap <Space> <C-f>
noremap - <C-b>
noremap <Backspace> <C-y>
noremap <Return> <C-e>
" insert change log in files
fun! InsertChangeLog()
let l:flag=0
for i in range(1,5)
if getline(i) !~ '.*Last Change.*'
let l:flag = l:flag + 1
endif
endfor
if l:flag >= 5
normal(1G)
call append(0, "File: <+Description+>")
call append(1, "Created: " . strftime("%a %d/%b/%Y hs %H:%M"))
call append(2, "Last Change: " . strftime("%a %d/%b/%Y hs %H:%M"))
call append(3, "author: <+your name+>")
call append(4, "site: <+site+>")
call append(5, "Twitter: <+your Twitter here+>")
normal gg
endif
endfun
map <special> <F4> <esc>:call InsertChangeLog()<cr>
" update changefile log
" http://tech.groups.yahoo.com/group/vim/message/51005
fun! LastChange()
let _s=@/
let l = line(".")
let c = col(".")
if line("$") >= 5
1,5s/\s*Last Change:\s*\zs.*/\="" . strftime("%Y %b %d %X")/ge
endif
let @/=_s
call cursor(l, c)
endfun
autocmd BufWritePre * keepjumps call LastChange()
function! JumpToNextPlaceholder()
let old_query = getreg('/')
echo search("<+.\\++>")
exec "norm! c/+>/e\<CR>"
call setreg('/', old_query)
endfunction
autocmd BufNewFile * :call LoadFileTemplate()
nnoremap <special> <leader>j :call JumpToNextPlaceholder()<CR>a
inoremap <special> <leader>j <ESC>:call JumpToNextPlaceholder()<CR>a
" Cientific calculator
command! -nargs=+ Calc :py print <args>
py from math import *
map ,c :Calc
set statusline=%F%m%r%h%w\
\ ft:%{&ft}\ \
\ff:%{&ff}\ \
\%{strftime(\"%a\ %d/%m/%Y\ \
\%H:%M:%S\",getftime(expand(\"%:p\")))}%=\ \
\buf:%n\ \
\L:%04l\ C:%04v\ \
\T:%04L\ HEX:%03.3B\ ASCII:%03.3b\ %P
set laststatus=2 " Always show statusline
ほとんどすべてが here です。特にC++では、主にプログラミング指向です。
これは私の謙虚な.vimrcです。これは進行中の作業であるため(常にそうであるように)、面倒なレイアウトとコメントアウトされた行はご容赦ください。
" =====Key mapping
" Insert empty line.
nmap <A-o> o<ESC>k
nmap <A-O> O<ESC>j
" Insert one character.
nmap <A-i> i <Esc>r
nmap <A-a> a <Esc>r
" Move on display lines in normal and visual mode.
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
" Do not lose * register when pasting on visual selection.
vmap p "zxP
" Clear highlight search results with <esc>
nnoremap <esc> :noh<return><esc>
" Center screen on next/previous selection.
map n nzz
map N Nzz
" <Esc> with jj.
inoremap jj <Esc>
" Switch jump to mark.
nnoremap ' `
nnoremap ` '
" Last and next jump should center too.
nnoremap <C-o> <C-o>zz
nnoremap <C-i> <C-i>zz
" Paste on new line.
nnoremap <A-p> :pu<CR>
nnoremap <A-S-p> :pu!<CR>
" Quick paste on insert mode.
inoremap <C-F> <C-R>"
" Indent cursor on empty line.
nnoremap <A-c> ddO
nnoremap <leader>c ddO
" Save and quit quickly.
nnoremap <leader>s :w<CR>
nnoremap <leader>q :q<CR>
nnoremap <leader>Q :q!<CR>
" The way it should have been.
noremap Y y$
" Moving in buffers.
nnoremap <C-S-tab> :bprev<CR>
nnoremap <C-tab> :bnext<CR>
" Using bufkill plugin.
nnoremap <leader>b :BD<CR>
nnoremap <leader>B :BD!<CR>
nnoremap <leader>ZZ :w<CR>:BD<CR>
" Moving and resizing in windows.
nnoremap + <C-W>+
nnoremap _ <C-W>-
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
nnoremap <leader>w <C-w>c
" Moving in tabs
noremap <c-right> gt
noremap <c-left> gT
nnoremap <leader>t :tabc<CR>
" Moving around in insert mode.
inoremap <A-j> <C-O>gj
inoremap <A-k> <C-O>gk
inoremap <A-h> <Left>
inoremap <A-l> <Right>
" =====General options
" I copy a lot from external apps.
set clipboard=unnamed
" Don't let swap and backup files fill my working directory.
set backupdir=c:\\temp,. " Backup files
set directory=c:\\temp,. " Swap files
set nocompatible
set showmatch
set hidden
set showcmd " This shows what you are typing as a command.
set scrolloff=3
" Allow backspacing over everything in insert mode
set backspace=indent,eol,start
" Syntax highlight
syntax on
filetype plugin on
filetype indent on
" =====Searching
set ignorecase
set hlsearch
set incsearch
" =====Indentation settings
" autoindent just copies the indentation from the line above.
"set autoindent
" smartindent automatically inserts one extra level of indentation in some cases.
set smartindent
" cindent is more customizable, but also more strict.
"set cindent
set tabstop=4
set shiftwidth=4
" =====GUI options.
" Just Vim without any gui.
set guioptions-=m
set guioptions-=T
set lines=40
set columns=150
" Consolas is better, but Courier new is everywhere.
"set guifont=Courier\ New:h9
set guifont=Consolas:h9
" Cool status line.
set statusline=%<%1*===\ %5*%f%1*%(\ ===\ %4*%h%1*%)%(\ ===\ %4*%m%1*%)%(\ ===\ %4*%r%1*%)\ ===%====\ %2*%b(0x%B)%1*\ ===\ %3*%l,%c%V%1*\ ===\ %5*%P%1*\ ===%0* laststatus=2
colorscheme mildblack
let g:sienna_style = 'dark'
" =====Plugins
" ===BufPos
nnoremap <leader>ob :call BufWipeout()<CR>
" ===SuperTab
" Map SuperTab to space key.
let g:SuperTabMappingForward = '<c-space>'
let g:SuperTabMappingBackward = '<s-c-space>'
let g:SuperTabDefaultCompletionType = 'context'
" ===miniBufExpl
" let g:miniBufExplMapWindowNavVim = 1
" let g:miniBufExplMapCTabSwitchBufs = 1
" let g:miniBufExplorerMoreThanOne = 0
" ===AutoClose
" let g:AutoClosePairs = {'(': ')', '{': '}', '[': ']', '"': '"', "'": "'"}
" ===NERDTree
nnoremap <leader>n :NERDTreeToggle<CR>
" ===delimitMate
let delimitMate = "(:),[:],{:}"
行番号と構文の強調表示。
set number
syntax on
引数なしでgVimを起動するときは、:find
などを実行できるように「プロジェクト」ディレクトリで開く必要があります。ただし、ファイルを使用して起動する場合、ディレクトリを切り替えたくないので、すぐそこにとどまります(一部、ファイルを開くように、開きたい!)。
if argc() == 0
cd $PROJECT_DIR
endif
現在のプロジェクトの任意のファイルから:find
を使用できるように、少なくともc:\work
に到達するまでsrc
name__またはscripts
name__を見つけてそれらに下降するまで、ディレクトリツリーを検索するパスを設定します私のプロジェクト。これにより、現在のプロジェクトではないファイルを開くことができます(つまり、上記のPROJECT_DIR
は別のディレクトリを指定します)。
set path+=src/**;c:/work,scripts/**;c:/work
そのため、gVimがフォーカスを失ったときに自動保存と再読み込みを行い、挿入モードを終了し、読み取り専用ファイルを編集するときにPerforceから自動チェックアウトするようにしています...
augroup AutoSaveGroup
autocmd!
autocmd FocusLost *.cpp,*.h,*.cs,*.rad*,Jam*,*.py,*.bat,*.mel wa
autocmd FileChangedRO *.cpp,*.h,*.cs,*.rad*,Jam*,*.py,*.bat,*.mel silent !p4 edit %:p
autocmd FileChangedRO *.cpp,*.h,*.cs,*.rad*,Jam*,*.py,*.bat,*.mel w!
augroup END
augroup OutOfInsert
autocmd!
autocmd FocusLost * call feedkeys("\<C-\>\<C-N>")
augroup END
最後に、現在のバッファ内のファイルのディレクトリに切り替えて、そのディレクトリ内の他のファイルを簡単に:e
できるようにします。
augroup MiscellaneousTomStuff
autocmd!
" make up for the deficiencies in 'autochdir'
autocmd BufEnter * silent! lcd %:p:h:gs/ /\\ /
augroup END
これが私の.vimrcです。 Gvim 7.2を使用します
set guioptions=em
set showtabline=2
set softtabstop=2
set shiftwidth=2
set tabstop=2
" Use spaces instead of tabs
set expandtab
set autoindent
" Colors and fonts
colorscheme inkpot
set guifont=Consolas:h11:cANSI
"TAB navigation like firefox
:nmap <C-S-tab> :tabprevious<cr>
:nmap <C-tab> :tabnext<cr>
:imap <C-S-tab> <ESC>:tabprevious<cr>i
:imap <C-tab> <ESC>:tabnext<cr>i
:nmap <C-t> :tabnew<cr>
:imap <C-t> <ESC>:tabnew<cr>i
:map <C-w> :tabclose<cr>
" No Backups and line numbers
set nobackup
set number
set nuw=6
" swp files are saved to %Temp% folder
set dir=$temp
" sets the default size of gvim on open
set lines=40 columns=90
私が広く使用する2つの関数は、ファイルにジャンプするためのプレースホルダーとInsertChangeLog()であり、共同で「よりわかりやすい説明でファイルの作成を容易にします。
" place holders snippets
" File Templates
" --------------
" <leader>j jumps to the next marker
" iabbr <buffer> for for <+i+> in <+intervalo+>:<cr><tab><+i+>
function! LoadFileTemplate()
"silent! 0r ~/.vim/templates/%:e.tmpl
syn match vimTemplateMarker "<+.\++>" containedin=ALL
hi vimTemplateMarker guifg=#67a42c guibg=#112300 gui=bold
endfunction
function! JumpToNextPlaceholder()
let old_query = getreg('/')
echo search("<+.\\++>")
exec "norm! c/+>/e\<CR>"
call setreg('/', old_query)
endfunction
autocmd BufNewFile * :call LoadFileTemplate()
nnoremap <leader>j :call JumpToNextPlaceholder()<CR>a
inoremap <leader>j <ESC>:call JumpToNextPlaceholder()<CR>a
fun! InsertChangeLog()
normal(1G)
call append(0, "Arquivo: <+Description+>")
call append(1, "Criado: " . strftime("%a %d/%b/%Y hs %H:%M"))
call append(2, "Last Change: " . strftime("%a %d/%b/%Y hs %H:%M"))
call append(3, "autor: <+digite seu nome+>")
call append(4, "site: <+digite o endereço de seu site+>")
call append(5, "Twitter: <+your Twitter here+>")
normal gg
endfun
マウスオーバーでフォールドコンテンツと構文グループを表示します。
function! SyntaxBallon()
let synID = synID(v:beval_lnum, v:beval_col, 0)
let groupID = synIDtrans(synID)
let name = synIDattr(synID, "name")
let group = synIDattr(groupID, "name")
return name . "\n" . group
endfunction
function! FoldBalloon()
let foldStart = foldclosed(v:beval_lnum)
let foldEnd = foldclosedend(v:beval_lnum)
let lines = []
if foldStart >= 0
" we are in a fold
let numLines = foldEnd - foldStart + 1
if (numLines > 17)
" show only the first 8 and the last 8 lines
let lines += getline(foldStart, foldStart + 8)
let lines += [ '-- Snipped ' . (numLines - 16) . ' lines --']
let lines += getline(foldEnd - 8, foldEnd)
else
" show all lines
let lines += getline(foldStart, foldEnd)
endif
endif
" return result
return join(lines, has("balloon_multiline") ? "\n" : " ")
endfunction
function! Balloon()
if foldclosed(v:beval_lnum) >= 0
return FoldBalloon()
else
return SyntaxBallon()
endfunction
set balloonexpr=Balloon()
set ballooneval
set nocompatible
syntax on
set number
set autoindent
set smartindent
set background=dark
set tabstop=4 shiftwidth=4
set tw=80
set expandtab
set mousehide
set cindent
set list listchars=tab:»·,trail:·
set autoread
filetype on
filetype indent on
filetype plugin on
" abbreviations for c programming
func LoadCAbbrevs()
" iabbr do do {<CR>} while ();<C-O>3h<C-O>
" iabbr for for (;;) {<CR>}<C-O>k<C-O>3l<C-O>
" iabbr switch switch () {<CR>}<C-O>k<C-O>6l<C-O>
" iabbr while while () {<CR>}<C-O>k<C-O>5l<C-O>
" iabbr if if () {<CR>}<C-O>k<C-O>2l<C-O>
iabbr #d #define
iabbr #i #include
endfunc
au FileType c,cpp call LoadCAbbrevs()
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g'\"" | endif
autocmd FileType python set nocindent shiftwidth=4 ts=4 foldmethod=indent
あまりありません。
あまり一般的ではないことがわかっている私のお気に入りのカスタマイズのいくつか:
" Windows *********************************************************************"
set equalalways " Multiple windows, when created, are equal in size"
set splitbelow splitright " Put the new windows to the right/bottom"
" Insert new line in command mode *********************************************"
map <S-Enter> O<ESC> " Insert above current line"
map <Enter> o<ESC> " Insert below current line"
" After selecting something in visual mode and shifting, I still want that"
" selection intact ************************************************************"
vmap > >gv
vmap < <gv
これの多くは wiki btwから来ています。
set nocompatible
source $VIMRUNTIME/mswin.vim
behave mswin
set nobackup
set tabstop=4
set nowrap
set guifont=Droid_Sans_Mono:h9:cANSI
colorscheme torte
set shiftwidth=4
set ic
syn off
set nohls
set acd
set autowrite
noremap \c "+yy
noremap \x "+dd
noremap \t :tabnew<CR>
noremap \2 I"<Esc>A"<Esc>
noremap \3 bi'<Esc>ea'<Esc>
noremap \" i"<Esc>ea"<Esc>
noremap ?2 Bi"<Esc>Ea"<Esc>
set matchpairs+=<:>
nnoremap <C-N> :next<CR>
nnoremap <C-P> :prev<CR>
nnoremap <Tab> :bnext<CR>
nnoremap <S-Tab> :bprevious<CR>
nnoremap \w :let @/=expand("<cword>")<Bar>split<Bar>normal n<CR>
nnoremap \W :let @/='\<'.expand("<cword>").'\>'<Bar>split<Bar>normal n<CR>
autocmd FileType xml exe ":silent %!xmllint --format --recover - "
autocmd FileType cpp set tabstop=2 shiftwidth=2 expandtab autoindent smarttab
autocmd FileType sql set tabstop=2 shiftwidth=2 expandtab autoindent smarttab
" Map key to toggle opt
function MapToggle(key, opt)
let cmd = ':set '.a:opt.'! \| set '.a:opt."?\<CR>"
exec 'nnoremap '.a:key.' '.cmd
exec 'inoremap '.a:key." \<C-O>".cmd
endfunction
command -nargs=+ MapToggle call MapToggle(<f-args>)
map <F6> :if exists("syntax_on") <Bar> syntax off <Bar> else <Bar> syntax enable <Bar> endif <CR>
" Display-altering option toggles
MapToggle <F7> hlsearch
MapToggle <F8> wrap
MapToggle <F9> list
" Behavior-altering option toggles
MapToggle <F10> scrollbind
MapToggle <F11> ignorecase
MapToggle <F12> paste
set pastetoggle=<F12>
C/C++およびsvnの使用に便利なもの(git/hg/whateverに合わせて簡単に変更できます)。 Fキーに設定します。
C#ではありませんが、それでも便利です。
function! SwapFilesKeep()
" Open a new window next to the current one with the matching .cpp/.h pair"
let command = "echo " . bufname("%") . "|sed s,\h$,\H,|sed s,cpp,h,|sed s,H$,cpp,"
let newfilename = system(command)
silent execute("vs " . newfilename)
endfunction
function! SwapFiles()
" swap between .cpp and .h "
let command = "echo " . bufname("%") . "|sed s,\h$,\H,|sed s,cpp,h,|sed s,H$,cpp,"
let newfilename = system(command)
silent execute("e " . newfilename)
endfunction
function! SvnDiffAll()
let tempfile = system("tempfile")
silent execute ":!svn diff .>" . tempfile
execute ":sf ".tempfile
return
endfunction
function! SvnLog()
let fn = expand('%')
let tempfile = system("tempfile")
silent execute ":!svn log -v " . fn . ">" . tempfile
execute ":sf ".tempfile
return
endfunction
function! SvnStatus()
let tempfile = system("tempfile")
silent execute ":!svn status .>" . tempfile
execute ":sf ".tempfile
return
endfunction
function! SvnDiff()
" diff with BASE "
let dir = expand('%:p:h')
let fn = expand('%')
let fn = substitute(fn,".*\\","","")
let fn = substitute(fn,".*/","","")
silent execute ":vert diffsplit " . dir . "/.svn/text-base/" . fn . ".svn-base"
silent execute ":set ft=cpp"
unlet fn dir
return
endfunction
Vimrcに加えて、プラグインのより大きなコレクションがあります。すべてが http://github.com/jceb/vimrc のgitリポジトリに保存されます。
" Author: Jan Christoph Ebersbach jceb AT e-jc DOT de
""""""""""""""""""""""""""""""""""""""""""""""""""
" ---------- Settings ----------
"
""""""""""""""""""""""""""""""""""""""""""""""""""
" Prevent modelines in files from being evaluated (avoids a potential
" security problem wherein a malicious user could write a hazardous
" modeline into a file) (override default value of 5)
set modeline
set modelines=5
" ########## miscellaneous options ##########
set nocompatible " Use Vim defaults instead of 100% vi compatibility
set whichwrap=<,> " Cursor key move the cursor to the next/previous line if pressed at the end/beginning of a line
set backspace=indent,eol,start " more powerful backspacing
set viminfo='20,\"50 " read/write a .viminfo file, don't store more than
set history=100 " keep 50 lines of command line history
set incsearch " Incremental search
set hidden " hidden allows to have modified buffers in background
set noswapfile " turn off backups and files
set nobackup " Don't keep a backup file
set magic " special characters that can be used in search patterns
set grepprg=grep\ --exclude='*.svn-base'\ -n\ $*\ /dev/null " don't grep through svn-base files
" Try do use the ack program when available
let tmp = ''
for i in ['ack', 'ack-grep']
let tmp = substitute (system ('which '.i), '\n.*', '', '')
if v:Shell_error == 0
exec "set grepprg=".tmp."\\ -a\\ -H\\ --nocolor\\ --nogroup"
break
endif
endfor
unlet tmp
"set autowrite " Automatically save before commands like :next and :make
" Suffixes that get lower priority when doing tab completion for filenames.
" These are files we are not likely to want to edit or read.
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc,.pdf,.exe
"set autochdir " move to the directory of the edited file
set ssop-=options " do not store global and local values in a session
set ssop-=folds " do not store folds
" ########## visual options ##########
set wildmenu " When 'wildmenu' is on, command-line completion operates in an enhanced mode.
set wildcharm=<C-Z>
set showmode " If in Insert, Replace or Visual mode put a message on the last line.
set guifont=monospace\ 8 " guifont + fontsize
set guicursor=a:blinkon0 " cursor-blinking off!!
set ruler " show the cursor position all the time
set nowrap " kein Zeilenumbruch
set foldmethod=indent " Standardfaltungsmethode
set foldlevel=99 " default fold level
set winminheight=0 " Minimal Windowheight
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set matchtime=2 " time to show the matching bracket
set hlsearch " highlight search
set linebreak
set lazyredraw " no readraw when running macros
set scrolloff=3 " set X lines to the curors - when moving vertical..
set laststatus=2 " statusline is always visible
set statusline=(%{bufnr('%')})\ %t\ \ %r%m\ #%{expand('#:t')}\ (%{bufnr('#')})%=[%{&fileformat}:%{&fileencoding}:%{&filetype}]\ %l,%c\ %P " statusline
"set mouse=n " mouse only in normal mode support in vim
"set foldcolumn=1 " show folds
set number " draw linenumbers
set nolist " list nonprintable characters
set sidescroll=0 " scroll X columns to the side instead of centering the cursor on another screen
set completeopt=menuone " show the complete menu even if there is just one entry
set listchars+=precedes:<,extends:> " display the following nonprintable characters
if $LANG =~ ".*\.UTF-8$" || $LANG =~ ".*utf8$" || $LANG =~ ".*utf-8$"
set listchars+=tab:»·,trail:·" display the following nonprintable characters
endif
set guioptions=aegitcm " disabled menu in gui mode
"set guioptions=aegimrLtT
set cpoptions=aABceFsq$ " q: When joining multiple lines leave the cursor at the position where it would be when joining two lines.
" $: When making a change to one line, don't redisplay the line, but put a '$' at the end of the changed text.
" v: Backspaced characters remain visible on the screen in Insert mode.
colorscheme peaksea " default color scheme
" default color scheme
" if &term == '' || &term == 'builtin_gui' || &term == 'dumb'
if has('gui_running')
set background=light " use colors that fit to a light background
else
set background=light " use colors that fit to a light background
"set background=dark " use colors that fit to a dark background
endif
syntax on " syntax highlighting
" ########## text options ##########
set smartindent " always set smartindenting on
set autoindent " always set autoindenting on
set backspace=2 " Influences the working of <BS>, <Del>, CTRL-W and CTRL-U in Insert mode.
set textwidth=0 " Don't wrap words by default
set shiftwidth=4 " number of spaces to use for each step of indent
set tabstop=4 " number of spaces a tab counts for
set noexpandtab " insert spaces instead of tab
set smarttab " insert spaces only at the beginning of the line
set ignorecase " Do case insensitive matching
set smartcase " overwrite ignorecase if pattern contains uppercase characters
set formatoptions=lcrqn " no automatic linebreak
set pastetoggle=<F11> " put vim in pastemode - usefull for pasting in console-mode
set fileformats=unix,dos,mac " favorite fileformats
set encoding=utf-8 " set default-encoding to utf-8
set iskeyword+=_,- " these characters also belong to a Word
set matchpairs+=<:>
""""""""""""""""""""""""""""""""""""""""""""""""""
" ---------- Special Configuration ----------
"
""""""""""""""""""""""""""""""""""""""""""""""""""
" ########## determine terminal encoding ##########
"if has("multi_byte") && &term != 'builtin_gui'
" set termencoding=utf-8
"
" " unfortunately the normal xterm supports only latin1
" if $TERM == "xterm" || $TERM == "xterm-color" || $TERM == "screen" || $TERM == "linux" || $TERM_PROGRAM == "GLterm"
" let propv = system("xprop -id $WINDOWID -f WM_LOCALE_NAME 8s ' $0' -notype WM_LOCALE_NAME")
" if propv !~ "WM_LOCALE_NAME .*UTF.*8"
" set termencoding=latin1
" endif
" endif
" " for the possibility of using a terminal to input and read chinese
" " characters
" if $LANG == "zh_CN.GB2312"
" set termencoding=euc-cn
" endif
"endif
" Set paper size from /etc/papersize if available (Debian-specific)
if filereadable('/etc/papersize')
let s:papersize = matchstr(system('/bin/cat /etc/papersize'), '\p*')
if strlen(s:papersize)
let &printoptions = "paper:" . s:papersize
endif
unlet! s:papersize
endif
""""""""""""""""""""""""""""""""""""""""""""""""""
" ---------- Autocommands ----------
"
""""""""""""""""""""""""""""""""""""""""""""""""""
filetype plugin on " automatically load filetypeplugins
filetype indent on " indent according to the filetype
if !exists("autocommands_loaded")
let autocommands_loaded = 1
augroup templates
" read templates
" au BufNewFile ?akefile,*.mk TSkeletonSetup Makefile
" au BufNewFile *.tex TSkeletonSetup latex.tex
" au BufNewFile build*.xml TSkeletonSetup antbuild.xml
" au BufNewFile test*.py,*Test.py TSkeletonSetup pyunit.py
" au BufNewFile *.py TSkeletonSetup python.py
augroup END
augroup filetypesettings
" Do Word completion automatically
au FileType debchangelog setl expandtab
au FileType asciidoc,mkd,txt,mail call DoFastWordComplete()
au FileType tex,plaintex setlocal makeprg=pdflatex\ \"%:p\"
au FileType mkd setlocal autoindent
au FileType Java,c,cpp setlocal noexpandtab nosmarttab
au FileType mail setlocal textwidth=70
au FileType mail call FormatMail()
au FileType mail setlocal formatoptions=tcrqan
au FileType mail setlocal comments+=b:--
au FileType txt setlocal formatoptions=tcrqn textwidth=72
au FileType asciidoc,mkd,tex setlocal formatoptions=tcrq textwidth=72
au FileType xml,docbk,xhtml,jsp setlocal formatoptions=tcrqn
au FileType Ruby setlocal shiftwidth=2
au BufReadPost,BufNewFile * set formatoptions-=o " o is really annoying
au BufReadPost,BufNewFile * call ReadIncludePath()
" Special Makefilehandling
au FileType automake,make setlocal list noexpandtab
au FileType xsl,xslt,xml,html,xhtml runtime! scripts/closetag.vim
" Omni completion settings
"au FileType c setlocal completefunc=ccomplete#Complete
au FileType css setlocal omnifunc=csscomplete#CompleteCSS
"au FileType html setlocal completefunc=htmlcomplete#CompleteTags
"au FileType js setlocal completefunc=javascriptcomplete#CompleteJS
"au FileType php setlocal completefunc=phpcomplete#CompletePHP
"au FileType python setlocal completefunc=pythoncomplete#Complete
"au FileType Ruby setlocal completefunc=rubycomplete#Complete
"au FileType sql setlocal completefunc=sqlcomplete#Complete
"au FileType * setlocal completefunc=syntaxcomplete#Complete
"au FileType xml setlocal completefunc=xmlcomplete#CompleteTags
au FileType help setlocal nolist
" insert a Prompt for every changed file in the commit message
"au FileType svn :1![ -f "%" ] && awk '/^[MDA]/ { print $2 ":\n - " }' %
augroup END
augroup hooks
" replace "Last Modified: with the current time"
au BufWritePre,FileWritePre * call LastMod()
" line highlighting in insert mode
autocmd InsertLeave * set nocul
autocmd InsertEnter * set cul
" move to the directory of the edited file
"au BufEnter * if isdirectory (expand ('%:p:h')) | cd %:p:h | endif
" jump to last position in the file
au BufRead * if line("'\"") > 0 && line("'\"") <= line("$") && &filetype != "mail" | exe "normal g`\"" | endif
" jump to last position every time a buffer is entered
"au BufEnter * if line("'x") > 0 && line("'x") <= line("$") && line("'y") > 0 && line("'y") <= line("$") && &filetype != "mail" | exe "normal g'yztg`x" | endif
"au BufLeave * if &modifiable | exec "normal mxHmy"
augroup END
augroup highlight
" make visual mode dark cyan
au FileType * hi Visual ctermfg=Black ctermbg=DarkCyan gui=bold guibg=#a6caf0
" make cursor red
au BufEnter,BufRead,WinEnter * :call SetCursorColor()
" hightlight trailing spaces and tabs and the defined print margin
"au FileType * hi WhiteSpaceEOL_Printmargin ctermfg=black ctermbg=White guifg=Black guibg=White
au FileType * hi WhiteSpaceEOL_Printmargin ctermbg=White guibg=White
au FileType * let m='' | if &textwidth > 0 | let m='\|\%' . &textwidth . 'v.' | endif | exec 'match WhiteSpaceEOL_Printmargin /\s\+$' . m .'/'
augroup END
endif
""""""""""""""""""""""""""""""""""""""""""""""""""
" ---------- Functions ----------
"
""""""""""""""""""""""""""""""""""""""""""""""""""
" set cursor color
function! SetCursorColor()
hi Cursor ctermfg=black ctermbg=red guifg=Black guibg=Red
endfunction
call SetCursorColor()
" change dir the root of a debian package
function! GetPackageRoot()
let sd = getcwd()
let owd = sd
let cwd = owd
let dest = sd
while !isdirectory('debian')
lcd ..
let owd = cwd
let cwd = getcwd()
if cwd == owd
break
endif
endwhile
if cwd != sd && isdirectory('debian')
let dest = cwd
endif
return dest
endfunction
" vim tip: Opening multiple files from a single command-line
function! Sp(dir, ...)
let split = 'sp'
if a:dir == '1'
let split = 'vsp'
endif
if(a:0 == 0)
execute split
else
let i = a:0
while(i > 0)
execute 'let files = glob (a:' . i . ')'
for f in split (files, "\n")
execute split . ' ' . f
endfor
let i = i - 1
endwhile
windo if expand('%') == '' | q | endif
endif
endfunction
com! -nargs=* -complete=file Sp call Sp(0, <f-args>)
com! -nargs=* -complete=file Vsp call Sp(1, <f-args>)
" reads the file .include_path - useful for C programming
function! ReadIncludePath()
let include_path = expand("%:p:h") . '/.include_path'
if filereadable(include_path)
for line in readfile(include_path, '')
exec "setl path +=," . line
endfor
endif
endfunction
" update last modified line in file
fun! LastMod()
let line = line(".")
let column = col(".")
let search = @/
" replace Last Modified in the first 20 lines
if line("$") > 20
let l = 20
else
let l = line("$")
endif
" replace only if the buffer was modified
if &mod == 1
silent exe "1," . l . "g/Last Modified:/s/Last Modified:.*/Last Modified: " .
\ strftime("%a %d. %b %Y %T %z %Z") . "/"
endif
let @/ = search
" set cursor to last position before substitution
call cursor(line, column)
endfun
" toggles show marks plugin
"fun! ToggleShowMarks()
" if exists('b:sm') && b:sm == 1
" let b:sm=0
" NoShowMarks
" setl updatetime=4000
" else
" let b:sm=1
" setl updatetime=200
" DoShowMarks
" endif
"endfun
" reformats an email
fun! FormatMail()
" workaround for the annoying mutt send-hook behavoir
silent! 1,/^$/g/^X-To: .*/exec 'normal gg'|exec '/^To: /,/^Cc: /-1d'|1,/^$/s/^X-To: /To: /|exec 'normal dd'|exec '?Cc'|normal P
silent! 1,/^$/g/^X-Cc: .*/exec 'normal gg'|exec '/^Cc: /,/^Bcc: /-1d'|1,/^$/s/^X-Cc: /Cc: /|exec 'normal dd'|exec '?Bcc'|normal P
silent! 1,/^$/g/^X-Bcc: .*/exec 'normal gg'|exec '/^Bcc: /,/^Subject: /-1d'|1,/^$/s/^X-Bcc: /Bcc: /|exec 'normal dd'|exec '?Subject'|normal P
" delete signature
silent! /^> --[\t ]*$/,/^-- $/-2d
" fix quotation
silent! /^\(On\|In\) .*$/,/^-- $/-1:s/>>/> >/g
silent! /^\(On\|In\) .*$/,/^-- $/-1:s/>\([^\ \t]\)/> \1/g
" delete inner and trailing spaces
normal :%s/[\xa0\x0d\t ]\+$//g
normal :%s/\([^\xa0\x0d\t ]\)[\xa0\x0d\t ]\+\([^\xa0\x0d\t ]\)/\1 \2/g
" format text
normal gg
" convert bad formated umlauts to real characters
normal :%s/\\\([0-9]*\)/\=nr2char(submatch(1))/g
normal :%s/&#\([0-9]*\);/\=nr2char(submatch(1))/g
" break undo sequence
normal iu
exec 'silent! /\(^\(On\|In\) .*$\|\(schrieb\|wrote\):$\)/,/^-- $/-1!par '.&tw.'gqs0'
" place the cursor before my signature
silent! /^-- $/-1
" clear search buffer
let @/ = ""
endfun
" insert selection at mark a
fun! Insert() range
exe "normal vgvmzomy\<Esc>"
normal `y
let lineA = line(".")
let columnA = col(".")
normal `z
let lineB = line(".")
let columnB = col(".")
" exchange marks
if lineA > lineB || lineA <= lineB && columnA > columnB
" save z in c
normal mc
" store y in z
normal `ymz
" set y to old z
normal `cmy
endif
exe "normal! gvd`ap`y"
endfun
" search with the selection of the visual mode
fun! VisualSearch(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == '#'
execute "normal! ?" . l:pattern . "^M"
elseif a:direction == '*'
execute "normal! /" . l:pattern . "^M"
elseif a:direction == '/'
execute "normal! /" . l:pattern
else
execute "normal! ?" . l:pattern
endif
let @/ = l:pattern
let @" = l:saved_reg
endfun
" 'Expandvar' expands the variable under the cursor
fun! <SID>Expandvar()
let origreg = @"
normal yiW
if (@" == "@\"")
let @" = origreg
else
let @" = eval(@")
endif
normal diW"0p
let @" = origreg
endfun
" execute the bc calculator
fun! <SID>Bc(exp)
setlocal paste
normal mao
exe ":.!echo 'scale=2; " . a:exp . "' | bc"
normal 0i "bDdd`a"bp
setlocal nopaste
endfun
fun! <SID>RFC(number)
silent exe ":e http://www.ietf.org/rfc/rfc" . a:number . ".txt"
endfun
" The function Nr2Hex() returns the Hex string of a number.
func! Nr2Hex(nr)
let n = a:nr
let r = ""
while n
let r = '0123456789ABCDEF'[n % 16] . r
let n = n / 16
endwhile
return r
endfunc
" The function String2Hex() converts each character in a string to a two
" character Hex string.
func! String2Hex(str)
let out = ''
let ix = 0
while ix < strlen(a:str)
let out = out . Nr2Hex(char2nr(a:str[ix]))
let ix = ix + 1
endwhile
return out
endfunc
" translates hex value to the corresponding number
fun! Hex2Nr(hex)
let r = 0
let ix = strlen(a:hex) - 1
while ix >= 0
let val = 0
if a:hex[ix] == '1'
let val = 1
elseif a:hex[ix] == '2'
let val = 2
elseif a:hex[ix] == '3'
let val = 3
elseif a:hex[ix] == '4'
let val = 4
elseif a:hex[ix] == '5'
let val = 5
elseif a:hex[ix] == '6'
let val = 6
elseif a:hex[ix] == '7'
let val = 7
elseif a:hex[ix] == '8'
let val = 8
elseif a:hex[ix] == '9'
let val = 9
elseif a:hex[ix] == 'a' || a:hex[ix] == 'A'
let val = 10
elseif a:hex[ix] == 'b' || a:hex[ix] == 'B'
let val = 11
elseif a:hex[ix] == 'c' || a:hex[ix] == 'C'
let val = 12
elseif a:hex[ix] == 'd' || a:hex[ix] == 'D'
let val = 13
elseif a:hex[ix] == 'e' || a:hex[ix] == 'E'
let val = 14
elseif a:hex[ix] == 'f' || a:hex[ix] == 'F'
let val = 15
endif
let r = r + val * Power(16, strlen(a:hex) - ix - 1)
let ix = ix - 1
endwhile
return r
endfun
" mathematical power function
fun! Power(base, exp)
let r = 1
let exp = a:exp
while exp > 0
let r = r * a:base
let exp = exp - 1
endwhile
return r
endfun
" Captialize movent/selection
function! Capitalize(type, ...)
let sel_save = &selection
let &selection = "inclusive"
let reg_save = @@
if a:0 " Invoked from Visual mode, use '< and '> marks.
silent exe "normal! `<" . a:type . "`>y"
elseif a:type == 'line'
silent exe "normal! '[V']y"
elseif a:type == 'block'
silent exe "normal! `[\<C-V>`]y"
else
silent exe "normal! `[v`]y"
endif
silent exe "normal! `[gu`]~`]"
let &selection = sel_save
let @@ = reg_save
endfunction
" Find file in current directory and edit it.
function! Find(...)
let path="."
if a:0==2
let path=a:2
endif
let l:list=system("find ".path. " -name '".a:1."' | grep -v .svn ")
let l:num=strlen(substitute(l:list, "[^\n]", "", "g"))
if l:num < 1
echo "'".a:1."' not found"
return
endif
if l:num != 1
let tmpfile = tempname()
exe "redir! > " . tmpfile
silent echon l:list
redir END
let old_efm = &efm
set efm=%f
if exists(":cgetfile")
execute "silent! cgetfile " . tmpfile
else
execute "silent! cfile " . tmpfile
endif
let &efm = old_efm
" Open the quickfix window below the current window
botright copen
call delete(tmpfile)
endif
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""
" ---------- Plugin Settings ----------
"
""""""""""""""""""""""""""""""""""""""""""""""""""
" hide dotfiles by default - the gh mapping quickly changes this behavior
let g:netrw_list_hide = '\(^\|\s\s\)\zs\.\S\+'
" Do not go to active window.
"let g:bufExplorerFindActive = 0
" Don't show directories.
"let g:bufExplorerShowDirectories = 0
" Sort by full file path name.
"let g:bufExplorerSortBy = 'fullpath'
" Show relative paths.
"let g:bufExplorerShowRelativePath = 1
" don't allow autoinstalling of scripts
let g:GetLatestVimScripts_allowautoinstall = 0
" load manpage-plugin
runtime! ftplugin/man.vim
" load matchit-plugin
runtime! macros/matchit.vim
" minibuf Explorer
"let g:miniBufExplModSelTarget = 1
"let g:miniBufExplorerMoreThanOne = 0
"let g:miniBufExplModSelTarget = 0
"let g:miniBufExplUseSingleClick = 1
"let g:miniBufExplMapWindowNavVim = 1
"let g:miniBufExplVSplit = 25
"let g:miniBufExplSplitBelow = 1
"let g:miniBufExplForceSyntaxEnable = 1
"let g:miniBufExplTabWrap = 1
" calendar plugin
" let g:calendar_weeknm = 4
" xml-ftplugin configuration
let xml_use_xhtml = 1
" :ToHTML
let html_number_lines = 1
let html_use_css = 1
let use_xhtml = 1
" LatexSuite
"let g:Tex_DefaultTargetFormat = 'pdf'
"let g:Tex_Diacritics = 1
" python-highlightings
let python_highlight_all = 1
" Eclim settings
"let org.eclim.user.name = g:tskelUserName
"let org.eclim.user.email = g:tskelUserEmail
"let g:EclimLogLevel = 4 " info
"let g:EclimBrowser = "x-www-browser"
"let g:EclimShowCurrentError = 1
" nnoremap <silent> <buffer> <tab> :call eclim#util#FillTemplate("${", "}")<CR>
" nnoremap <silent> <buffer> <leader>i :JavaImport<CR>
" nnoremap <silent> <buffer> <leader>d :JavaDocSearch -x declarations<CR>
" nnoremap <silent> <buffer> <CR> :JavaSearchContext<CR>
" nnoremap <silent> <buffer> <CR> :AntDoc<CR>
" quickfix notes plugin
map <Leader>n <Plug>QuickFixNote
nnoremap <F6> :QFNSave ~/.vimquickfix/
nnoremap <S-F6> :e ~/.vimquickfix/
nnoremap <F7> :cgetfile ~/.vimquickfix/
nnoremap <S-F7> :caddfile ~/.vimquickfix/
nnoremap <S-F8> :!rm ~/.vimquickfix/
" EnhancedCommentify updated keybindings
vmap <Leader><Space> <Plug>VisualTraditional
nmap <Leader><Space> <Plug>Traditional
let g:EnhCommentifyTraditionalMode = 'No'
let g:EnhCommentifyPretty = 'No'
let g:EnhCommentifyRespectIndent = 'Yes'
" FuzzyFinder keybinding
nnoremap <leader>fb :FufBuffer<CR>
nnoremap <leader>fd :FufDir<CR>
nnoremap <leader>fD :FufDir <C-r>=expand('%:~:.:h').'/'<CR><CR>
nmap <leader>Fd <leader>fD
nmap <leader>FD <leader>fD
nnoremap <leader>ff :FufFile<CR>
nnoremap <leader>fF :FufFile <C-r>=expand('%:~:.:h').'/'<CR><CR>
nmap <leader>FF <leader>fF
nnoremap <leader>ft :FufTextMate<CR>
nnoremap <leader>fr :FufRenewCache<CR>
"let g:FuzzyFinderOptions = {}
"let g:FuzzyFinderOptions = { 'Base':{}, 'Buffer':{}, 'File':{}, 'Dir':{},
"\ 'MruFile':{}, 'MruCmd':{}, 'Bookmark':{},
"\ 'Tag':{}, 'TaggedFile':{},
"\ 'GivenFile':{}, 'GivenDir':{}, 'GivenCmd':{},
"\ 'CallbackFile':{}, 'CallbackItem':{}, }
let g:fuf_onelinebuf_location = 'botright'
let g:fuf_maxMenuWidth = 300
let g:fuf_file_exclude = '\v\~$|\.o$|\.exe$|\.bak$|\.swp$|((^|[/\\])\.[/\\]$)|\.pyo|\.pyc|autom4te\.cache|blib|_build|\.bzr|\.cdv|cover_db|CVS|_darcs|\~\.dep|\~\.dot|\.git|\.hg|\~\.nib|\.pc|\~\.plst|RCS|SCCS|_sgbak|\.svn'
" YankRing
nnoremap <silent> <F8> :YRShow<CR>
let g:yankring_history_file = '.yankring_history_file'
let g:yankring_replace_n_pkey = '<c-\>'
let g:yankring_replace_n_nkey = '<c-m>'
" supertab
let g:SuperTabDefaultCompletionType = "<c-n>"
" TagList
let Tlist_Show_One_File = 1
" UltiSnips
"let g:UltiSnipsJumpForwardTrigger = "<tab>"
"let g:UltiSnipsJumpBackwardTrigger = "<S-tab>"
" NERD Commenter
nmap <leader><space> <plug>NERDCommenterToggle
vmap <leader><space> <plug>NERDCommenterToggle
imap <C-c> <ESC>:call NERDComment(0, "insert")<CR>
" disable unused Mark mappings
nmap <leader>_r <plug>MarkRegex
vmap <leader>_r <plug>MarkRegex
nmap <leader>_n <plug>MarkClear
vmap <leader>_n <plug>MarkClear
nmap <leader>_* <plug>MarkSearchCurrentNext
nmap <leader>_# <plug>MarkSearchCurrentPrev
nmap <leader>_/ <plug>MarkSearchAnyNext
nmap <leader>_# <plug>MarkSearchAnyPrev
nmap <leader>__* <plug>MarkSearchNext
nmap <leader>__# <plug>MarkSearchPrev
" Nerd Tree Explorer mapping
nmap <leader>e :NERDTree<CR>
" TaskList settings
let g:tlWindowPosition = 1
""""""""""""""""""""""""""""""""""""""""""""""""""
" ---------- Keymappings ----------
"
""""""""""""""""""""""""""""""""""""""""""""""""""
" edit/reload .vimrc-Configuration
nnoremap gce :e $HOME/.vimrc<CR>
nnoremap gcl :source $HOME/.vimrc<CR>:echo "Configuration reloaded"<CR>
" un/hightlight current line
nnoremap <silent> <Leader>H :match<CR>
nnoremap <silent> <Leader>h mk:exe 'match Search /<Bslash>%'.line(".").'l/'<CR>
" spellcheck off, german, englisch
nnoremap gsg :setlocal invspell spelllang=de<CR>
nnoremap gse :setlocal invspell spelllang=en<CR>
" switch to previous/next buffer
nnoremap <silent> <c-p> :bprevious<CR>
nnoremap <silent> <c-n> :bnext<CR>
" kill/delete trailing spaces and tabs
nnoremap <Leader>kt msHmt:silent! %s/[\t \x0d]\+$//g<CR>:let @/ = ""<CR>:echo "Deleted trailing spaces"<CR>'tzt`s
vnoremap <Leader>kt :s/[\t \x0d]\+$//g<CR>:let @/ = ""<CR>:echo "Deleted trailing, spaces"<CR>
" kill/reduce inner spaces and tabs to a single space/tab
nnoremap <Leader>ki msHmt:silent! %s/\([^\xa0\x0d\t ]\)[\xa0\x0d\t ]\+\([^\xa0\x0d\t ]\)/\1 \2/g<CR>:let @/ = ""<CR>:echo "Deleted inner spaces"<CR>'tzt`s
vnoremap <Leader>ki :s/\([^\xa0\x0d\t ]\)[\xa0\x0d\t ]\+\([^\xa0\x0d\t ]\)/\1 \2/g<CR>:let @/ = ""<CR>:echo "Deleted inner spaces"<CR>
" start new undo sequences when using certain commands in insert mode
inoremap <C-U> <C-G>u<C-U>
inoremap <C-W> <C-G>u<C-W>
inoremap <BS> <C-G>u<BS>
inoremap <C-H> <C-G>u<C-H>
inoremap <Del> <C-G>u<Del>
" swap two words
" http://www.vim.org/tips/tip.php?tip_id=329
nmap <silent> gw "_yiw:s/\(\%#[ÄÖÜäöüßa-zA-Z0-9]\+\)\(\_W\+\)\([ÄÖÜäöüßa-zA-Z0-9]\+\)/\3\2\1/<CR><C-o><C-l>:let @/ = ""<CR>
nmap <silent> gW "_yiW:s/\(\%#[ÄÖÜäöüßa-zA-Z0-9-+*_]\+\)\(\_W\+\)\([ÄÖÜäöüßa-zA-Z0-9-+*_]\+\)/\3\2\1/<CR><C-o><C-l>:let @/ = ""<CR>
" Capitalize movement
nnoremap <silent> gC :set opfunc=Capitalize<CR>g@
vnoremap <silent> gC :<C-U>call Capitalize(visualmode(), 1)<CR>
" delete search-register
nnoremap <silent> <leader>/ :let @/ = ""<CR>
" browse current buffer/selection in www-browser
nnoremap <Leader>b :!x-www-browser %:p<CR>:echo "WWW-Browser started"<CR>
vnoremap <Leader>b y:!x-www-browser <C-R>"<CR>:echo "WWW-Browser started"<CR>
" lookup/translate inner/selected Word in dictionary
" recode is only needed for non-utf-8-text
" nnoremap <Leader>T mayiw`a:exe "!dict -P - -- $(echo " . @" . "\| recode latin1..utf-8)"<CR>
"nnoremap <Leader>t mayiw`a:exe "!dict -P - -- " . @"<CR>
" vnoremap <Leader>T may`a:exe "!dict -P - -- $(echo " . @" . "\| recode latin1..utf-8)"<CR>
"vnoremap <Leader>t may`a:exe "!dict -P - -- " . @"<CR>
" delete words in insert mode like expected - doesn't work properly at
" the end of the line
inoremap <C-BS> <C-w>
" Switch buffers
nnoremap <silent> [b :ls<Bar>let nr = input("Buffer: ")<Bar>if nr != ''<Bar>exe ":b " . nr<Bar>endif<CR>
" Search for the occurence of the Word under the cursor
nnoremap <silent> [I [I:le
私の~/.vimrc
はかなり標準です(ほとんどが$VIMRUNTIME/vimrc_example.vim
)が、~/.vim
と~/.vim/ftplugin
のカスタムスクリプトで、~/.vim/syntax
ディレクトリを広範囲に使用しています。
.vimrcのスーパーマネーの部分は、タブがある場所ごとに「"」文字を表示する方法と、「悪い」空白を赤で強調表示する方法です。悪い空白とは、行の中央にあるタブや、末尾にある見えないスペースのようなものです。
syntax enable
" Incremental search without highlighting.
set incsearch
set nohlsearch
" Show ruler.
set ruler
" Try to keep 2 lines above/below the current line in view for context.
set scrolloff=2
" Other file types.
autocmd BufReadPre,BufNew *.xml set filetype=xml
" Flag problematic whitespace (trailing spaces, spaces before tabs).
highlight BadWhitespace term=standout ctermbg=red guibg=red
match BadWhitespace /[^* \t]\zs\s\+$\| \+\ze\t/
" If using ':set list' show things nicer.
execute 'set listchars=tab:' . nr2char(187) . '\ '
set list
highlight Tab ctermfg=lightgray guifg=lightgray
2match Tab /\t/
" Indent settings for code: 4 spaces, do not use tab character.
"set tabstop=4 shiftwidth=4 autoindent smartindent shiftround
"autocmd FileType c,cpp,Java,xml,python,cs setlocal expandtab softtabstop=4
"autocmd FileType c,cpp,Java,xml,python,cs 2match BadWhitespace /[^\t]\zs\t/
set tabstop=8 shiftwidth=4 autoindent smartindent shiftround
set expandtab softtabstop=4
2match BadWhitespace /[^\t]\zs\t\+/
" Automatically show matching brackets.
set showmatch
" Auto-complete file names after <TAB> like bash does.
set wildmode=longest,list
set wildignore=.svn,CVS,*.swp
" Show current mode and currently-typed command.
set showmode
set showcmd
" Use mouse if possible.
" set mouse=a
" Use Ctrl-N and Ctrl-P to move between files.
nnoremap <C-N> :confirm next<Enter>
nnoremap <C-P> :confirm prev<Enter>
" Confirm saving and quitting.
set confirm
" So yank behaves like delete, i.e. Y = D.
map Y y$
" Toggle paste mode with F5.
set pastetoggle=<F5>
" Don't exit visual mode when shifting.
vnoremap < <gv
vnoremap > >gv
" Move up and down by visual lines not buffer lines.
nnoremap <Up> gk
vnoremap <Up> gk
nnoremap <Down> gj
vnoremap <Down> gj
私の.vimrcのお気に入りは、マクロを操作するための一連のマッピングです。
nnoremap <Leader>qa mqGo<Esc>"ap
nnoremap <Leader>qb mqGo<Esc>"bp
nnoremap <Leader>qc mqGo<Esc>"cp
<SNIP>
nnoremap <Leader>qz mqGo<Esc>"zp
nnoremap <Leader>Qa G0"ad$dd'q
nnoremap <Leader>Qb G0"bd$dd'q
nnoremap <Leader>Qc G0"cd$dd'q
<SNIP>
nnoremap <Leader>Qz G0"zd$dd'q
これにより、\ q [az]は位置をマークし、現在のファイルの最後に指定されたレジスタの内容を出力し、\ Q [az]は最後の行の内容を指定されたレジスタに入れて、マークされた場所。マクロを編集したり、1つのマクロを新しいレジスタにコピーして微調整したりするのが本当に簡単になります。
my .vimrc 。私のWordスワップ機能は通常大ヒットです。
"{{{1 Защита от множественных загрузок
if exists("b:dollarHOMEslashdotvimrcFileLoaded")
finish
endif
let b:dollarHOMEslashdotvimrcFileLoaded=1
" set t_Co=8
" set t_Sf=[3%p1%dm
" set t_Sb=[4%p1%dm
"{{{1 Options
"{{{2 set
set nocompatible
set background=dark
set display+=lastline
"set iminsert=0
"set imsearch=0
set grepprg=grep\ -nH\ $*
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set backspace=indent,eol,start
set autoindent
set nosmartindent
set backup
set conskey
set bioskey
set browsedir=buffer
" bomb may work bad
set nobomb
exe "set backupdir=".$HOME."/.vimbackup,."
set backupext=~
set history=32
set ruler
set showcmd
set hlsearch
set incsearch
set nocindent
set textwidth=80
set complete=.,i,d,t,w,b,u,k
" set conskey
set noconfirm
set cscopetag
set cscopetagorder=1
" set copyindent
" !may be not safe
set exrc
set secure
" set foldclose
set noswapfile
" set swapsync=sync
set fsync
set guicursor="a:block-blinkoff0"
set autowriteall
set hidden
set nojoinspaces
set nostartofline
" set virtualedit+=onemore
set lazyredraw
set visualbell
set makeef=make.##.err.log
set modelines=16
set more
set virtualedit+=block
set winaltkeys=no
set fileencodings=utf-8,cp1251,koi8-r,default
set encoding=utf-8
set list
set listchars=tab:>-,trail:-,nbsp:_
set magic
set pastetoggle=<F1>
set foldmethod=marker
set wildmenu
set wildcharm=<Tab>
set formatoptions=arcoqn12w
"set formatoptions+=t
set scrolloff=2
"{{{3 define keys
"{{{4 get keys from zkbd
if isdirectory($HOME."/.zkbd") &&
\filereadable($HOME."/.zkbd/".$TERM."-pc-linux-gnu")
let s:keys=split(system("cat ".
\shellescape($HOME."/.zkbd/".$TERM."-pc-linux-gnu").
\" | grep \"^key\\\\[\" | ".
\"sed -re \"s/^key\\\\[([[:alnum:]]*)\\\\]='(.*)'\\$".
\"/\\\\1=\\\\2/g\""), "\\n")
for key in s:keys
let tmp=split(key, "=")
if tmp[0]=~"^F\\d\\+$"
execute "set <".tmp[0].">=".
\substitute(tmp[1], "\\^\\[", "\<ESC>", "g")
endif
endfor
endif
" function g:DefineKeys()
"{{{4 screen
if 0 && $_SECONDLAUNCH
set <F1>=[11~
set <F2>=[12~
set <F3>=[13~
set <F4>=[14~
set <F5>=[15~
set <F6>=[17~
set <F7>=[18~
set <F8>=[19~
set <F9>=[20~
set <F10>=[21~
set <F11>=[23~
set <F12>=[24~
set <S-F1>=[23~
set <S-F2>=[24~
set <S-F3>=[25~
set <S-F4>=[26~
set <S-F5>=[28~
set <S-F6>=[29~
set <S-F7>=[31~
set <S-F8>=[32~
set <S-F9>=[33~
set <S-F10>=[34~
set <S-F11>=[23$
set <S-F12>=[24$
set <HOME>=[7~
set <END>=[8~
"{{{4 xterm
elseif $TERM=="xterm"
set <M-a>=a
set <M-b>=b
set <M-c>=c
set <M-d>=d
set <M-e>=e
set <M-f>=f
set <M-g>=g
set <M-h>=h
set <M-i>=i
set <M-j>=j
set <M-k>=k
set <M-l>=l
set <M-m>=m
set <M-n>=n
set <M-o>=o
set <M-p>=p
set <M-q>=q
set <M-r>=r
set <M-s>=s
set <M-t>=t
set <M-u>=u
set <M-v>=v
set <M-w>=w
set <M-x>=x
set <M-y>=y
set <M-z>=z
"set <M-SPACE>=
"set <Left>=OD
"set <S-Left>=O2D
"set <C-Left>=O5D
"set <Right>=OC
"set <S-Right>=O2C
"set <C-Right>=O5C
"set <Up>=OA
"set <S-Up>=O2A
"set <C-Up>=O5A
"set <Down>=OB
"set <S-Down>=O2B
"set <C-Down>=O5B
set <F1>=[11~
set <F2>=[12~
set <F3>=[13~
set <F4>=[14~
set <F5>=[15~
set <F6>=[17~
set <F7>=[18~
set <F8>=[19~
set <F9>=[20~
set <F10>=[21~
set <F11>=[23~
set <F12>=[24~
"set <C-F1>=
"set <C-F2>=
"set <C-F3>=
"set <C-F4>=
"set <C-F5>=[15;5~
"set <C-F6>=[17;5~
"
"set <C-F7>=[18;5~
"set <C-F8>=[19;5~
"set <C-F9>=[20;5~
"set <C-F10>=[21;5~
"set <C-F11>=[23;5~
"set <C-F12>=[24;5~
set <S-F1>=[11;2~
set <S-F2>=[12;2~
set <S-F3>=[13;2~
set <S-F4>=[14;2~
set <S-F5>=[15;2~
set <S-F6>=[17;2~
set <S-F7>=[18;2~
set <S-F8>=[19;2~
set <S-F9>=[20;2~
set <S-F10>=[21;2~
set <S-F11>=[23;2~
set <S-F12>=[24;2~
set <END>=OF
set <S-END>=O2F
set <S-HOME>=O2H
set <HOME>=OH
set <DEL>=
" set <PageUp>=[5~
" set <PageDown>=[6~
" noremap <DEL>
" inoremap <DEL>
" cnoremap <DEL>
set <S-Del>=[3;2~
" set <C-Del>=[3;5~
" set <M-Del>=[3;3~
"{{{4 rxvt --- aterm
elseif $TERM=="rxvt"
set <M-a>=a
set <M-b>=b
set <M-c>=c
set <M-d>=d
set <M-e>=e
set <M-f>=f
set <M-g>=g
set <M-h>=h
set <M-i>=i
set <M-j>=j
set <M-k>=k
set <M-l>=l
set <M-m>=m
set <M-n>=n
set <M-o>=o
set <M-p>=p
set <M-q>=q
set <M-r>=r
set <M-s>=s
set <M-t>=t
set <M-u>=u
set <M-v>=v
set <M-w>=w
set <M-x>=x
set <M-y>=y
set <M-z>=z
set <F1>=OP
set <F2>=OQ
set <F3>=OR
set <F4>=OS
set <F5>=[15~
set <F6>=[17~
set <F7>=[18~
set <F8>=[19~
set <F9>=[20~
set <F10>=[21~
set <F11>=[23~
set <F12>=[24~
set <S-F1>=[23~
set <S-F2>=[24~
set <S-F3>=[25~
set <S-F4>=[26~
set <S-F5>=[28~
set <S-F6>=[29~
set <S-F7>=[31~
set <S-F8>=[32~
set <S-F9>=[33~
set <S-F10>=[34~
set <S-F11>=[23$
set <S-F12>=[24$
" set <C-S-F2>=[24^
" set <C-S-F3>=[25^
" set <C-S-F4>=[26^
" set <C-S-F5>=[28^
" set <C-S-F6>=[29^
" set <C-S-F7>=[31^
" set <C-S-F8>=[32^
" set <C-S-F9>=[33^
" set <C-S-F10>=[34^
" set <C-S-F11>=[23@
" set <C-S-F12>=[24@
" set <M-F5>=<F5>
" set <M-F6>=<F6>
" set <M-F7>=<F7>
" set <M-F8>=<F8>
" set <M-F9>=<F9>
" set <M-F10>=<F10>
" set <M-F11>=<F11>
" set <M-F12>=<F12>
" set <M-S-F5>=<S-F5>
" set <M-S-F6>=<S-F6>
" set <M-S-F7>=<S-F7>
" set <M-S-F8>=<S-F8>
" set <M-S-F9>=<S-F9>
" set <M-S-F10>=<S-F10>
" set <M-S-F11>=<S-F11>
" set <M-S-F12>=<S-F12>
"{{{4 rxvt-unicode --- urxvt
elseif $TERM=="rxvt-unicode"
set <M-a>=a
set <M-b>=b
set <M-c>=c
set <M-d>=d
set <M-e>=e
set <M-f>=f
set <M-g>=g
set <M-h>=h
set <M-i>=i
set <M-j>=j
set <M-k>=k
set <M-l>=l
set <M-m>=m
set <M-n>=n
set <M-o>=o
set <M-p>=p
set <M-q>=q
set <M-r>=r
set <M-s>=s
set <M-t>=t
set <M-u>=u
set <M-v>=v
set <M-w>=w
set <M-x>=x
set <M-y>=y
set <M-z>=z
set <F1>=[11~
set <F2>=[12~
set <F3>=[13~
set <F4>=[14~
set <F5>=[15~
set <F6>=[17~
set <F7>=[18~
set <F8>=[19~
set <F9>=[20~
set <F10>=[21~
set <F11>=[23~
set <F12>=[24~
" fluxbox!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
set <S-F1>=[23~
set <S-F2>=[24~
set <S-F3>=[25~
set <S-F4>=[26~
set <S-F5>=[28~
set <S-F6>=[29~
set <S-F7>=[31~
set <S-F8>=[32~
set <S-F9>=[33~
set <S-F10>=[34~
set <S-F11>=[23$
set <S-F12>=[24$
" set <C-F1>=[11^
" set <C-F2>=[12^
" set <C-F3>=[13^
" set <C-F4>=[14^
" set <C-F5>=[15^
" set <C-F6>=[17^
" set <C-F7>=[18^
" set <C-F8>=[19^
" set <C-F9>=[20^
" set <C-F10>=[21^
" set <C-F11>=[23^
" set <C-F12>=[24^
" openbox!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
" set <S-F1>=[23~
" set <S-F2>=[24~
" set <S-F3>=[25~
" set <S-F4>=[26~
" set <S-F5>=[28~
" set <S-F6>=[29~
" set <S-F7>=[31~
" set <S-F8>=[32~
" set <S-F9>=[33~
" set <S-F10>=[34~
" set <S-F11>=[23$
" set <S-F12>=[24$
" set <C-S-F2>=[24^
" set <C-S-F3>=[25^
" set <C-S-F4>=[26^
" set <C-S-F5>=[28^
" set <C-S-F6>=[29^
" set <C-S-F7>=[31^
" set <C-S-F8>=[32^
" set <C-S-F9>=[33^
" set <C-S-F10>=[34^
" set <C-S-F11>=[23@
" set <C-S-F12>=[24@
" set <M-F5>=<F5>
" set <M-F6>=<F6>
" set <M-F7>=<F7>
" set <M-F8>=<F8>
" set <M-F9>=<F9>
" set <M-F10>=<F10>
" set <M-F11>=<F11>
" set <M-F12>=<F12>
" set <M-S-F5>=<S-F5>
" set <M-S-F6>=<S-F6>
" set <M-S-F7>=<S-F7>
" set <M-S-F8>=<S-F8>
" set <M-S-F9>=<S-F9>
" set <M-S-F10>=<S-F10>
" set <M-S-F11>=<S-F11>
" set <M-S-F12>=<S-F12>
endif
" autocmd! DefineKeys
" endfunction
" "{{{4 autocmd
" augroup DefineKeys
" autocmd BufEnter * call g:DefineKeys()
" augroup END
"{{{2 filetipe
filetype plugin indent on
syntax on
"{{{2 let
"{{{ NERDCommenter
let NERDShutUp=1
let NERDSpaceDelims=1
"}}}
let g:c_syntax_for_h=1
let g:xml_syntax_folding=1
let paste_mode=0 " 0 = normal, 1 = paste
"{{{3 keys if $TERM=="rxvt-unicode"
" " fluxbox!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
" let g:C_F1="\<ESC>[11^"
" let g:C_F2="\<ESC>[12^"
" let g:C_F3="\<ESC>[13^"
" let g:C_F4="\<ESC>[14^"
" let g:C_F5="\<ESC>[15^"
" let g:C_F6="\<ESC>[17^"
" let g:C_F7="\<ESC>[18^"
" let g:C_F8="\<ESC>[19^"
" let g:C_F9="\<ESC>[20^"
" let g:C_F10="\<ESC>[21^"
" let g:C_F11="\<ESC>[23^"
" let g:C_F12="\<ESC>[24^"
" let g:M_S_F1="\<ESC>\<ESC>[23$"
" let g:M_S_F2="\<ESC>\<ESC>[24$"
" let g:M_S_F3="\<ESC>\<ESC>[25$"
" let g:M_S_F4="\<ESC>\<ESC>[26$"
" let g:M_S_F5="\<ESC>\<ESC>[28$"
" let g:M_S_F6="\<ESC>\<ESC>[29$"
" let g:M_S_F7="\<ESC>\<ESC>[31$"
" let g:M_S_F8="\<ESC>\<ESC>[32$"
" let g:M_S_F9="\<ESC>\<ESC>[33$"
" let g:M_S_F10="\<ESC>\<ESC>[34$"
" let g:M_S_F11="\<ESC>\<ESC>[23$"
" let g:M_S_F12="\<ESC>\<ESC>[24$"
" let g:M_C_F1="\<ESC>\<ESC>[11^"
" let g:M_C_F2="\<ESC>\<ESC>[12^"
" let g:M_C_F3="\<ESC>\<ESC>[13^"
" let g:M_C_F4="\<ESC>\<ESC>[14^"
" let g:M_C_F5="\<ESC>\<ESC>[15^"
" let g:M_C_F6="\<ESC>\<ESC>[17^"
" let g:M_C_F7="\<ESC>\<ESC>[18^"
" let g:M_C_F8="\<ESC>\<ESC>[19^"
" let g:M_C_F9="\<ESC>\<ESC>[20^"
" let g:M_C_F10="\<ESC>\<ESC>[21^"
" let g:M_C_F11="\<ESC>\<ESC>[23^"
" let g:M_C_F12="\<ESC>\<ESC>[24^"
" endif
"{{{3 Настройки :TOhtml
let html_number_lines=1
" let html_ignore_folding=1
let html_use_css=1
let html_no_pre=0
let use_xhtml=1
"{{{3 Предотвратить загрузку
let loaded_cmdalias=0
"{{{3 Mine
" let g:kmaps={"en": "", "ru": "russian-dvp"}
"{{{1 Syntax
highlight TooLongLine term=reverse ctermfg=Yellow ctermbg=Red
2match TooLongLine /\S\%>81v/
"{{{1 Autocommands
autocmd VimLeavePre * silent mksession! ~/.vim/lastSession.vim
au BufWritePost * if getline(1) =~ "^#!" | execute "silent! !chmod a+x %" |
\endif
autocmd BufRead,BufWinEnter * let &l:modifiable=(!(&ro && !&bt=="quickfix"))
"{{{1 Digraphs
digraphs ca 94 "^
digraphs ga 96 "`
digraphs ti 126 "~
"{{{1 Menus
" menu Encoding.koi8-r :e ++enc=8bit-koi8-r<CR>
" menu Encoding.windows-1251 :e ++enc=8bit-cp1251<CR>
" menu Encoding.ibm-866 :e ++enc=8bit-ibm866<CR>
" menu Encoding.utf-8 :e ++enc=2byte-utf-8<CR>
" menu Encoding.ucs-2le :e ++enc=ucs-2le<CR>
"{{{1 Команды
function s:Substitute(sstring, line1, line2)
execute a:line1.",".a:line2."!Perl -pi -e 'use encoding \"utf8\"; s'".
\escape(shellescape(a:sstring), '%!').
\" 2>/dev/null"
endfunction
command -range=% -nargs=+ S call s:Substitute(<q-args>, <line1>, <line2>)
"{{{1 Mappings
"{{{2 Menu mappings
"{{{2 function mappings
"
"{{{3 Function Eatchar
function Eatchar(pat)
let l:pat=((a:pat=="")?("*"):(a:pat))
let c = nr2char(getchar(0))
return (c =~ l:pat) ? '' : c
endfunction
"{{{3 CleverTab - tab to autocomplete and move indent
function CleverTab()
if strpart( getline('.'), col('.')-2, 1) =~ '^\k$'
return "\<C-n>"
else
return "\<Tab>"
endif
endfunction
inoremap <Tab> <C-R>=CleverTab()<CR>
"{{{3 Keymap switch
function! SwitchKeymap(kmaps, knum)
let s:kmapvals=values(a:kmaps)
if a:knum=="+"
let s:ki=index(s:kmapvals, &keymap)
echo s:ki
if s:ki==-1
let &keymap=s:kmapvals[0]
return
elseif s:ki>=len(a:kmaps)-1
let &keymap=s:kmapvals[0]
return
endif
let &keymap=s:kmapvals[s:ki+1]
return
elseif has_key(a:kmaps, a:knum)
let &keymap=a:kmaps[a:knum]
return
endif
let s:ki=0
for val in s:kmapvals
if s:ki==a:knum
let &keymap=val
return
endif
let s:ki+=1
endfor
let &keymap=s:kmapvals[0]
endfunction
" inoremap <S-Tab> <C-\><C-o>:call<SPACE>SwitchKeymap(g:kmaps,<SPACE>"+")<C-m>
"{{{2 ToggleVerbose
function! ToggleVerbose()
let g:verboseflag = !g:verboseflag
if g:verboseflag
exe "set verbosefile=".$HOME."/.logs/vim/verbose.log
set verbose=15
else
set verbose=0
set verbosefile=
endif
endfunction
noremap <F4>sv :call<SPACE>ToggleVerbose()
inoremap <F4>sv <C-o>:call<SPACE>ToggleVerbose()
"{{{2 Other mappings
"{{{3 <.*F12> mappings - for some browsing
noremap <F12> :TlistToggle<CR>
inoremap <F12> <C-O>:TlistToggle<CR>
inoremap <S-F12> <C-O>:BufExplorer<CR>
noremap <S-F12> :BufExplorer<CR>
inoremap <M-F12> <C-O>:NERDTreeToggle<CR>
noremap <M-F12> :NERDTreeToggle<CR>
"{{{3 yank/paste
vnoremap <C-Insert> "+y
nnoremap <S-Insert> "+p
inoremap <S-Insert> <C-o><S-Insert>
vnoremap p "_da<C-r><C-r>"<CR><ESC>
"{{{3 Motions
"{{{4 Left/Right replace
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
inoremap <C-b> <C-\><C-o>h
inoremap <C-f> <C-o>a
cnoremap <M-b> <C-Right>
inoremap <M-b> <C-o>w
inoremap <M-f> <C-o>b
cnoremap <M-f> <C-Left>
"{{{4 Page Up/Down
nnoremap <C-b> <C-U><C-U>
inoremap <PageUp> <C-O><C-U><C-O><C-U>
nnoremap <C-f> <C-D><C-D>
inoremap <PageDown> <C-O><C-D><C-O><C-D>
"{{{4 Up/Down
inoremap <C-G> <C-\><C-o>gk
inoremap <Up> <C-\><C-o>gk
inoremap <Down> <C-\><C-o>gj
inoremap <C-l> <C-\><C-o>gj
nnoremap <Down> gj
vnoremap <Down> gj
nnoremap j gj
vnoremap j gj
nnoremap gj j
vnoremap gj j
nnoremap gk k
vnoremap gk k
nnoremap k gk
vnoremap k gk
nnoremap <Up> gk
vnoremap <Up> gk
"{{{4 Smart <HOME> and <END>
" imap <HOME> <C-o>g^
" imap <C-O>g^<HOME> <C-o>^
" inoremap <C-o>^<HOME> <C-o>0
" imap <END> <C-o>g$
" inoremap <C-o>g$<END> <C-o>$
" nmap <HOME> <C-o>g^
" nmap <C-O>g^<HOME> ^
" nnoremap <C-o>^<HOME> 0
" nmap <END> g$
" nnoremap <C-o>g$<END> $
"{{{3 <F3> and searching
noremap <F3> :nohl<CR>
inoremap <S-F3> <C-o>:nohl<CR>
inoremap <F3> <C-o>n
"{{{3 <F2> for saving, <F10> for exiting
noremap <F2> :up<CR>
inoremap <F2> <C-o>:up<CR>
inoremap <F10> <ESC>ZZ
noremap <F10> <ESC>ZZ
inoremap <S-F10> <ESC>:q!<CR>
noremap <S-F10> :q!<CR>
inoremap <C-F10> <ESC>:silent<SPACE>mksession<SPACE>session.vim<CR>:wq!
noremap <C-F10> :silent<SPACE>mksession<SPACE>session.vim<CR>:wq!
"{{{3 Something
inoremap <C-z> <C-o>u
noremap <F1> :set paste!<C-m>
inoremap <C-^> <C-O><C-^>
inoremap <C-d> <Del>
cnoremap <C-d> <Del>
"{{{3 <C-j>
inoremap <C-j>j <C-o>:bn<CR>
inoremap <C-j>J <C-o>:bN<CR>
noremap <C-j>j :bn<CR>
noremap <C-j>J :bN<CR>
"{{{3 for visual
inoremap <S-Left> <C-o>vge
inoremap <S-Up> <C-o>vk
inoremap <S-Down> <C-o>vj
inoremap <S-Right> <C-o>ve
inoremap <S-End> <C-o>v$
inoremap <S-Home> <C-o>v$o^
vnoremap A <C-c>i
"{{{3 <F4>
"{{{4 <F4> folds
noremap <F4>{ a{{{<ESC>
inoremap <F4>{ {{{
noremap <F4>} a}}}<ESC>
inoremap <F4>} }}}
inoremap <F4>[ <C-o>o{{{<C-o>:call NERDComment(0,"norm")<C-m>
noremap <F4>[ o{{{<C-o>:call NERDComment(0,"norm")<C-m>
inoremap <F4>] <C-o>o}}}<C-o>:call NERDComment(0,"norm")<C-m>
noremap <F4>] o}}}<C-o>:call NERDComment(0,"norm")<C-m>
"{{{4 <F4> folds
inoremap <F4>f <C-o>za<C-o>j<C-o>^
noremap <F4>f zaj
"{{{4 <F4> yank/paste/delete
inoremap <F4>p <C-o>p
inoremap <F4>gp <C-o>"+p
inoremap <F4>y( <C-o>ya)
inoremap <F4>yl <C-o>yy
inoremap <F4>gy( <C-o>"+ya)
inoremap <F4>gyl <C-o>"+yy
inoremap <F4>P <C-o>P
inoremap <F4>d( <C-o>da)
inoremap <F4>dl <C-o>dd
"{{{4 <F4> frequently used expressions
inoremap <F4>c \033[m<C-/><C-o>h
"{{{4 <F4> alternate
imap <F4>a <C-o>:A<C-m>
map <F4>a :A<C-m>
"}}}
"}}}
"{{{3 «,»
"
" &lower
" &upper
" &1st
" &2nd
" &both lower and upper (or both 1st and 2nd)
" prefixed with &e
" prefixed with &E
" is &Prefix for smth
" &prefixed with (([what]p(prefix)))
" -: nothing
" +: added
" /: replaced
" [invc]: for modes insert, normal, visual, command (for insert mode if
" omitted)
" | vimrc | | | | |
" | i n v c | tex | c | html | vim | other
" ----+-----------------+--------+--------+-------+-------+---------------------
" a | l l | | | | |
" b | b - - b | +Pu | +eb+Eb | | |
" c | l b | +u | | | |
" d | b b b | | | | |
" e | Pl Pl | | +l+Pu | | |
" f | b(eb) - - b | | | | /u | zsh:+el
" g | | | | | |
" h | b(el) - - b(el) | /u | | | | sh:/u+eu
" i | l l - l | | | | |
" j | | | | | |
" k | | | | | |
" l | l | +Pu | | | | make:+u
" m | l l | /[in]m | +u | | |
" n | l | /l+u | | /l | /l |
" o | l | | | | |
" p | - - - b | +el | | | |
" q | b(eb) | +Pl | | | |
" r | | +u | | | |
" s | l(el) - - b | +u | +u | | +u+eu | make,Perl,zsh:+u
" t | b(el) - - l | +eu | | | |
" u | l - - b | | | +u | +u |
" v | | | | | |
" w | b - - b | | | | |
" x | | | | | |
" y | l l l | | | | |
" z | | | | | |
" ' " | b | /b | | | |
" ; : | 1 | | | | |
" , . | b 2 - 1 | | | +e2 | |
" ? ! | | | | | |
" < > | | +b | | +b+eb | +1 |
" - _ | | +1 | | +b | |
" @ / | b | | | | |
" = | | | | | |
"
"{{{4 insert
inoremap ,<SPACE> ,<SPACE>
inoremap ,<Esc> ,
inoremap ,<BS> <Nop>
inoremap ,ef <C-o>I{<C-m><C-o>o}<C-o>O
inoremap ,eF <C-m>{<C-m><C-o>o}<C-o>O
inoremap ,F {<C-o>o}<C-o>O
inoremap ,f {}<C-\><C-o>h
inoremap ,h []<C-\><C-o>h
inoremap ,s ()<C-\><C-o>h
inoremap ,u <LT>><C-\><C-o>h
inoremap ,es (<C-\><C-o>E<C-o>a)<C-\><C-o>h
inoremap ,H [[::]]<C-o>F:
inoremap ,eh [::]<C-o>F:
inoremap ,, \
inoremap ,. <C-o>==
inoremap ,w <C-o>w
inoremap ,W <C-o>W
inoremap ,b <C-o>b
inoremap ,B <C-o>B
inoremap ,a <C-o>A
inoremap ,i <C-o>I
inoremap ,l <C-o>o
inoremap ,o <C-o>O
inoremap ,dw <C-o>"zdaw
inoremap ,p <C-o>"zp
inoremap ,P <C-o>"zP
inoremap ,yw <C-o>"zyaw
inoremap ,y <C-o>"zy
inoremap ,d <C-o>"zd
inoremap ,D <C-o>"_d
inoremap ,c <C-o>:call<SPACE>NERDComment(0,"toggle")<C-m>
inoremap ,ec <C-o>:call<SPACE>NERDComment(0,"toEOL")<C-m>
inoremap ,t <C-r>=Tr3transliterate(input("Translit: "))<C-m>
inoremap ,T <C-o>b<C-o>"tdiw<C-r><C-r>=Tr3transliterate(@t)<C-m>
inoremap ,et <C-o>B<C-o>"tdiW<C-r><C-r>=Tr3transliterate(@t)<C-m>
inoremap ,/ <C-x><C-f>
inoremap ,@ <C-o>:w!<C-m>
inoremap ,; <C-o>%
inoremap ,m <C-\><C-o>:call system("make &")<C-m>
inoremap ,n \<C-m>
inoremap ,q «»<C-\><C-o>h
inoremap ,Q „“<C-\><C-o>h
inoremap ,eq “”<C-\><C-o>h
inoremap ,eQ ‘’<C-\><C-o>h
inoremap ," ""<C-\><C-o>h
inoremap ,' ''<C-\><C-o>h
"{{{4 visual
vnoremap ,y "zy
vnoremap ,d "zd
vnoremap ,D "_d
vnoremap ,p "zp
"{{{4 command
cnoremap ,s ()<Left>
cnoremap ,S \(\)<Left><Left>
cnoremap ,U \<LT>\><Left><Left>
cnoremap ,u <LT>><Left>
cnoremap ,F \{}<Left>
cnoremap ,f {}<Left>
cnoremap ,h []<Left>
cnoremap ,H [[::]]<Left><Left><Left>
cnoremap ,eh [::]<Left><Left>
cnoremap ,i <Home>
cnoremap ,a <End>
cnoremap ,, \
cnoremap ,. <C-r>:
cnoremap ,p <C-r>"
cnoremap ,P <C-r>+
cnoremap ,z <C-r>z
cnoremap ,t <C-r>=Tr3transliterate(input("Translit: "))<C-m>
cnoremap ,b <C-Left>
cnoremap ,w <C-Right>
cnoremap ,B <C-Left>
cnoremap ,W <C-Right>
"{{{4 normal
nnoremap ,C :!
nnoremap ,c :call<SPACE>NERDComment(0,"toggle")<C-m>
nnoremap ,d "_
nnoremap ,D "_d
nnoremap ,m :call system("make &")<C-m>
nnoremap ,a $
nnoremap ,i ^
nnoremap ,, ==
nnoremap ,y "zy
nnoremap ,p "zp
nnoremap ,P "zP
"{{{1 Functions
"{{{1
nohlsearch
" vim: ft=vim:fenc=utf-8:ts=4
Vimrcの一部と、vimrcからのファイルを以下に示します。
" F10 inverts 'wrap'
xnoremap <F10> :<C-U>set wrap! <Bar> set wrap? <CR>gv
nnoremap <F10> :set wrap! <Bar> set wrap? <CR>
inoremap <F10> <C-O>:set wrap! <Bar> set wrap? <CR>
" Shift-F10 inverts 'virtualedit'
xnoremap <S-F10> :<C-U>set ve=<C-R>=(&ve == 'all') ? '' : 'all'<return> ve?<CR>gv
nnoremap <S-F10> :set ve=<C-R>=(&ve == 'all') ? '' : 'all'<return> ve?<CR>
inoremap <S-F10> <C-O>:set ve=<C-R>=(&ve == 'all') ? '' : 'all'<return> ve?<CR>
" Ctrl-F10 inverts 'hidden'
xnoremap <C-F10> :<C-U>set hidden! <Bar> set hidden? <CR>gv
nnoremap <C-F10> :set hidden! <Bar> set hidden? <CR>
inoremap <C-F10> <C-O>:set hidden! <Bar> set hidden? <CR>
" F11 and F12 to go to resp. previous and next item in quickfix entries
nnoremap <F11> :silent! cc<CR>:silent! cp <CR>:call ErrBlink()<CR>
nnoremap <F12> :silent! cc<CR>:silent! cn <CR>:call ErrBlink()<CR>
" Shift-F11 and Shift-F12 to go to resp prev. and next file in quickfix list
nnoremap <S-F11> :silent! cc<CR>:silent! cpf<CR>:call ErrBlink()<CR>
nnoremap <S-F12> :silent! cc<CR>:silent! cnf<CR>:call ErrBlink()<CR>
" Ctrl-F11 and Ctrl-F1 to recall older and newer quickfix lists
nnoremap <C-F11> :silent! col <CR>:call ErrBlink()<CR>
nnoremap <C-F12> :silent! cnew<CR>:call ErrBlink()<CR>
xnoremap <silent> _* :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy/<C-R><C-R>/\|<C-R><C-R>=substitute(
\substitute(escape(@", '/\.*$^~['), '\s\+', '\\s\\+', 'g'), '\_s\+', '\\_s*', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
xnoremap <silent> _# :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy?<C-R><C-R>/\|<C-R><C-R>=substitute(
\substitute(escape(@", '?\.*$^~['), '\s\+', '\\s\\+', 'g'), '\_s\+', '\\_s*', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
xnoremap <silent> * :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy/<C-R><C-R>=substitute(
\substitute(escape(@", '/\.*$^~['), '\s\+', '\\s\\+', 'g'), '\_s\+', '\\_s*', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
xnoremap <silent> # :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy?<C-R><C-R>=substitute(
\substitute(escape(@", '?\.*$^~['), '\s\+', '\\s\\+', 'g'), '\_s\+', '\\_s*', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
set grepprg=ack
" F2 uses ack to search a Perl pattern
nnoremap <F2> :grep<space>
nnoremap <S-F2> :grepadd<space>
" F3 uses vim to search current pattern
nnoremap <F3> :noautocmd vim // **/*<C-F>Bhhi
nnoremap <F3><F3> :noautocmd vim /<C-R><C-O>// **/*<Return>
" F3 to search the current highlighted pattern
xnoremap <F3> "zy:noautocmd vim /\M<C-R>=escape(@z,'\/')<CR>/ **/*<CR>
nnoremap <S-F3> :noautocmd vimgrepadd // **/*<C-F>Bhhi
nnoremap <S-F3><S-F3> :noautocmd vimgrepadd /<C-R><C-O>// **/*<Return>
xnoremap <S-F3> "zy:noautocmd vimgrepadd /\M<C-R>=escape(@z,'\/')<CR>/ **/*<CR>
xnoremap p pgvy
" Have cursor line and column blink a bit
function! BlinkHere()
for i in range(1,6)
set cursorline! cursorcolumn!
redraw
sleep 30m
endfor
endfunction
" Blink on mappings to quickfix commands
function! ErrBlink()
silent! cw
silent! normal! z17
silent! cc
silent! normal! zz
silent! call BlinkHere()
endfunction
function! s:CompareQuickfixEntries(i1, i2)
if bufname(a:i1.bufnr) == bufname(a:i2.bufnr)
return a:i1.lnum == a:i2.lnum ? 0 : (a:i1.lnum < a:i2.lnum ? -1 : 1)
else
return bufname(a:i1.bufnr) < bufname(a:i2.bufnr) ? -1 : 1
endif
endfunction
function! s:SortUniqQFList()
let sortedList = sort(getqflist(), 's:CompareQuickfixEntries')
let uniqedList = []
let last = ''
for item in sortedList
let this = bufname(item.bufnr) . "\t" . item.lnum
if this !=# last
call add(uniqedList, item)
let last = this
endif
endfor
call setqflist(uniqedList)
endfunction
autocmd! QuickfixCmdPost * call s:SortUniqQFList()
:map + v%zf#「+」を押して、関数を折りたたんだり、括弧内のすべてをループします。
:set expandtab#タブはts(tabspace)の設定に従ってスペースとして展開されます
http://github.com/elventails/vim/blob/master/vimrc
CakePHP/PHP/Gitの追加機能があります
楽しい!
あなたが使用している素敵なオプションを追加し、レポを更新します。
乾杯、
テキストをプライベートのPastebinに自動的に送信する関数を作成しました。
let g:pfx='' " prefix for private Pastebin.
function PBSubmit()
python << EOF
import vim
import urllib2 as url
import urllib
pfx = vim.eval( 'g:pfx' )
URL = 'http://'
if pfx == '':
URL += 'Pastebin.com/Pastebin.php'
else:
URL += pfx + '.Pastebin.com/Pastebin.php'
data = urllib.urlencode( { 'code2': '\n'.join( vim.current.buffer ).decode( 'utf-8' ).encode( 'latin-1' ),
'email': '',
'expiry': 'd',
'format': 'text',
'parent_pid': '',
'paste': 'Send',
'poster': '' } )
url.urlopen( URL, data )
print 'Submitted to ' + URL
EOF
endfunction
map <Leader>pb :call PBSubmit()<CR>
次のようなことを強調するドキュメントを行うための独自の構文またはチェックリストを作成しました
->これを行う(太字)
!->今これを行う(オレンジ色)
++>プロセスでこれを行う(緑色)
=>これは完了です(グレー)
./syntax/にfc_comdoc.vimとしてドキュメントがあります
vimrcで、カスタム拡張子が.txtcdまたは.txtapの場合にこの構文を設定する
au BufNewFile,BufRead *.txtap,*.txtcd setf fc_comdoc
set ai
set si
set sm
set sta
set ts=3
set sw=3
set co=130
set lines=50
set nowrap
set ruler
set showcmd
set showmode
set showmatch
set incsearch
set hlsearch
set gfn=Consolas:h11
set guioptions-=T
set clipboard=unnamed
set expandtab
set nobackup
syntax on
colors torte
今すぐこれを見ました:
:nnoremap <esc> :noh<return><esc>
ViEmuブログ で見つけたので、これを本当に掘り下げました。簡単な説明-通常モードでEscが検索ハイライトをオフにします。
set tabstop=4
set shiftwidth=4
set cindent
set noautoindent
set noexpandtab
set nocompatible
set cino=:0(4u0
set backspace=indent,start
set term=ansi
let lpc_syntax_for_c=1
syntax enable
autocmd FileType c set cin noai nosi
autocmd FileType lpc set cin noai nosi
autocmd FileType css set nocin ai noet
autocmd FileType js set nocin ai noet
autocmd FileType php set nocin ai noet
function! DeleteFile(...)
if(exists('a:1'))
let theFile=a:1
elseif ( &ft == 'help' )
echohl Error
echo "Cannot delete a help buffer!"
echohl None
return -1
else
let theFile=expand('%:p')
endif
let delStatus=delete(theFile)
if(delStatus == 0)
echo "Deleted " . theFile
else
echohl WarningMsg
echo "Failed to delete " . theFile
echohl None
endif
return delStatus
endfunction
"delete the current file
com! Rm call DeleteFile()
"delete the file and quit the buffer (quits vim if this was the last file)
com! RM call DeleteFile() <Bar> q!
set guifont=FreeMono\ 12
colorscheme default
set nocompatible
set backspace=indent,eol,start
set nobackup "do not keep a backup file, use versions instead
set history=10000 "keep 10000 lines of command line history
set ruler "show the cursor position all the time
set showcmd "display incomplete commands
set showmode
set showmatch
set nojoinspaces "do not insert a space, when joining lines
set whichwrap="" "do not jump to the next line when deleting
"set nowrap
filetype plugin indent on
syntax enable
set hlsearch
set incsearch "do incremental searching
set autoindent
set noexpandtab
set tabstop=4
set shiftwidth=4
set number
set laststatus=2
set visualbell "do not beep
set tabpagemax=100
set statusline=%F\ %h%m%r%=%l/%L\ \(%-03p%%\)\ %-03c\
"use listmode to make tabs visible and make them gray so they are not
"disctrating too much
set listchars=tab:»\ ,eol:¬,trail:.
highlight NonText ctermfg=gray guifg=gray
highlight SpecialKey ctermfg=gray guifg=gray
highlight clear MatchParen
highlight MatchParen cterm=bold
set list
match Todo /@todo/ "highlight doxygen todos
"different tabbing settings for different file types
if has("autocmd")
autocmd FileType c setlocal tabstop=4 softtabstop=4 shiftwidth=4 expandtab
autocmd FileType cpp setlocal tabstop=4 softtabstop=4 shiftwidth=4 expandtab
autocmd FileType go setlocal tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab
autocmd FileType make setlocal tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab
autocmd FileType python setlocal tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab
" doesnt work properly -- revise me
autocmd CursorMoved * call RonnyHighlightWordUnderCursor()
autocmd CursorMovedI * call RonnyHighlightWordUnderCursor()
"jump to the end of the file if it is a logfile
autocmd BufReadPost *.log normal G
autocmd BufRead,BufNewFile *.go set filetype=go
endif
highlight Search ctermfg=white ctermbg=gray
highlight IncSearch ctermfg=white ctermbg=gray
highlight RonnyWordUnderCursorHighlight cterm=bold
function! RonnyHighlightWordUnderCursor()
python << endpython
import vim
# get the character under the cursor
row, col = vim.current.window.cursor
characterUnderCursor = ''
try:
characterUnderCursor = vim.current.buffer[row-1][col]
except:
pass
# remove last search
vim.command("match RonnyWordUnderCursorHighlight //")
# if the cursor is currently located on a real Word, move on and highlight it
if characterUnderCursor.isalpha() or characterUnderCursor.isdigit() or characterUnderCursor is '_':
# expand cword to get the Word under the cursor
wordUnderCursor = vim.eval("expand(\'<cword>\')")
if wordUnderCursor is None :
wordUnderCursor = ""
# escape the Word
wordUnderCursor = vim.eval("RonnyEscapeString(\"" + wordUnderCursor + "\")")
wordUnderCursor = "\<" + wordUnderCursor + "\>"
currentSearch = vim.eval("@/")
if currentSearch != wordUnderCursor :
# highlight it, if it is not the currently searched Word
vim.command("match RonnyWordUnderCursorHighlight /" + wordUnderCursor + "/")
endpython
endfunction
function! RonnyEscapeString(s)
python << endpython
import vim
s = vim.eval("a:s")
escapeMap = {
'"' : '\\"',
"'" : '\\''',
"*" : '\\*',
"/" : '\\/',
#'' : ''
}
s = s.replace('\\', '\\\\')
for before, after in escapeMap.items() :
s = s.replace(before, after)
vim.command("return \'" + s + "\'")
endpython
endfunction
.vimrcを http://dotfiles.org/~petdance/.vimrc に置き、 dotfiles.orgの他のファイルも にします。
私が長年vimをいじっていた結果は、すべて ここ です。
" **************************
" * vim general options ****
" **************************
set nocompatible
set history=1000
set mouse=a
" don't have files trying to override this .vimrc:
set nomodeline
" have <F1> Prompt for a help topic, rather than displaying the introduction
" page, and have it do this from any mode:
nnoremap <F1> :help<Space>
vmap <F1> <C-C><F1>
omap <F1> <C-C><F1>
map! <F1> <C-C><F1>
set title
" **************************
" * set visual options *****
" **************************
set nu
set ruler
syntax on
" colorscheme oceandeep
set background=dark
set wildmenu
set wildmode=list:longest,full
" use "[RO]" for "[readonly]"
set shortmess+=r
set scrolloff=3
" display the current mode and partially-typed commands in the status line:
set showmode
set showcmd
" don't make it look like there are line breaks where there aren't:
set nowrap
" **************************
" * set editing options ****
" **************************
set autoindent
filetype plugin indent on
set backspace=eol,indent,start
autocmd FileType text setlocal textwidth=80
autocmd FileType make set noexpandtab shiftwidth=8
" * Search & Replace
" make searches case-insensitive, unless they contain upper-case letters:
set ignorecase
set smartcase
" show the `best match so far' as search strings are typed:
set incsearch
" assume the /g flag on :s substitutions to replace all matches in a line:
set gdefault
" ***************************
" * tab completion **********
" ***************************
setlocal omnifunc=syntaxcomplete#Complete
imap <Tab> <C-x><C-o>
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
" ***************************
" * keyboard mapping ********
" ***************************
imap <A-1> <Esc>:tabn 1<CR>i
imap <A-2> <Esc>:tabn 2<CR>i
imap <A-3> <Esc>:tabn 3<CR>i
imap <A-4> <Esc>:tabn 4<CR>i
imap <A-5> <Esc>:tabn 5<CR>i
imap <A-6> <Esc>:tabn 6<CR>i
imap <A-7> <Esc>:tabn 7<CR>i
imap <A-8> <Esc>:tabn 8<CR>i
imap <A-9> <Esc>:tabn 9<CR>i
map <A-1> :tabn 1<CR>
map <A-2> :tabn 2<CR>
map <A-3> :tabn 3<CR>
map <A-4> :tabn 4<CR>
map <A-5> :tabn 5<CR>
map <A-6> :tabn 6<CR>
map <A-7> :tabn 7<CR>
map <A-8> :tabn 8<CR>
map <A-9> :tabn 9<CR>
" ***************************
" * Utilities Needed ********
" ***************************
function InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
" end of .vimrc
私は.vimrcを異なるセクションに分割する傾向がありますので、実行するすべての異なるマシンで異なるセクションをオン/オフすることができます。
"*****************************************
"* SECTION 1 - THINGS JUST FOR GVIM *
"*****************************************
if v:version >= 700
"Note: Other plugin files
source ~/.vim/ben_init/bens_pscripts.vim
"source ~/.vim/ben_init/stim_projects.vim
"source ~/.vim/ben_init/temp_commands.vim
"source ~/.vim/ben_init/wwatch.vim
"Extract sections of code as a function (works in C, C++, Perl, Java)
source ~/.vim/ben_init/functify.vim
"Settings that relate to the look/feel of vim in the GUI
source ~/.vim/ben_init/gui_settings.vim
"General VIM settings
source ~/.vim/ben_init/general_settings.vim
"Settings for programming
source ~/.vim/ben_init/c_programming.vim
"Settings for completion
source ~/.vim/ben_init/completion.vim
"My own templating system
source ~/.vim/ben_init/templates.vim
"Abbreviations and interesting key mappings
source ~/.vim/ben_init/abbrev.vim
"Plugin configuration
source ~/.vim/ben_init/plugin_config.vim
"Wiki configuration
source ~/.vim/ben_init/wiki_config.vim
"Key mappings
source ~/.vim/ben_init/key_mappings.vim
"Auto commands
source ~/.vim/ben_init/autocmds.vim
"Handy Functions written by other people
source ~/.vim/ben_init/handy_functions.vim
"My own omni_completions
source ~/.vim/ben_init/bens_omni.vim
endif
これが私の共有してくれてありがとう。 vimプラグインに関するその他の情報は、ここで見つけることができます: http://github.com/ametaireau/dotfiles/
それが役に立てば幸い。
" My .vimrc configuration file.
" =============================
"
" Plugins
" -------
" Comes with a set of utilities to enhance the user experience.
" Django and python snippets are possible thanks to the snipmate
" plugin.
"
" A also uses taglist and NERDTree vim plugins.
"
" Shortcuts
" ----------
" Here are some shortcuts I like to use when editing text using VIM:
"
" <alt-left/right> to navigate trough tabs
" <ctrl-e> to display the explorator
" <ctrl-p> for the code explorator
" <ctrl-space> to autocomplete
" <ctrl-n> enter tabnew to open a new file
" <alt-h> highlight the lines of more than 80 columns
" <ctrl-h> set textwith to 80 cols
" <maj-k> when on a python file, open the related pydoc documentation
" ,v and ,V to show/edit and reload the vimrc configuration file
colorscheme evening
syntax on " syntax highlighting
filetype on " to consider filetypes ...
filetype plugin on " ... and in plugins
set directory=~/.vim/swp " store the .swp files in a specific path
set expandtab " enter spaces when tab is pressed
set tabstop=4 " use 4 spaces to represent tab
set softtabstop=4
set shiftwidth=4 " number of spaces to use for auto indent
set autoindent " copy indent from current line on new line
set number " show line numbers
set backspace=indent,eol,start " make backspaces more powerful
set ruler " show line and column number
set showcmd " show (partial) command in status line
set incsearch " highlight search
set noignorecase
set infercase
set nowrap
" shortcuts
map <c-n> :tabnew
map <silent><c-e> :NERDTreeToggle <cr>
map <silent><c-p> :TlistToggle <cr>
nnoremap <a-right> gt
nnoremap <a-left> gT
command W w !Sudo tee % > /dev/null
map <buffer> K :execute "!pydoc " . expand("<cword>")<CR>
map <F2> :set textwidth=80 <cr>
" Replace trailing slashes
map <F3> :%s/\s\+$//<CR>:exe ":echo'trailing slashes removes'"<CR>
map <silent><F6> :QFix<CR>
" edit vim quickly
map ,v :sp ~/.vimrc<CR><C-W>_
map <silent> ,V :source ~/.vimrc<CR>:filetype detect<CR>:exe ":echo'vimrc reloaded'"<CR>
" configure expanding of tabs for various file types
au BufRead,BufNewFile *.py set expandtab
au BufRead,BufNewFile *.c set noexpandtab
au BufRead,BufNewFile *.h set noexpandtab
au BufRead,BufNewFile Makefile* set noexpandtab
" remap CTRL+N to CTRL + space
inoremap <Nul> <C-n>
" Omnifunc completers
autocmd FileType python set omnifunc=pythoncomplete#Complete
" Tlist configuration
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_Close_On_Select = 0
let Tlist_Auto_Update = 1
let Tlist_Process_File_Always = 1
let Tlist_Use_Right_Window = 1
let Tlist_WinWidth = 40
let Tlist_Show_One_File = 1
let Tlist_Show_Menu = 0
let Tlist_File_Fold_Auto_Close = 0
let Tlist_Ctags_Cmd = '/usr/bin/ctags'
let tlist_css_settings = 'css;e:SECTIONS'
" NerdTree configuration
let NERDTreeIgnore = ['\.pyc$', '\.pyo$']
" Highlight more than 80 columns lines on demand
nnoremap <silent><F1>
\ :if exists('w:long_line_match') <Bar>
\ silent! call matchdelete(w:long_line_match) <Bar>
\ unlet w:long_line_match <Bar>
\ elseif &textwidth > 0 <Bar>
\ let w:long_line_match = matchadd('ErrorMsg', '\%>'.&tw.'v.\+', -1) <Bar>
\ else <Bar>
\ let w:long_line_match = matchadd('ErrorMsg', '\%>80v.\+', -1) <Bar>
\ endif<CR>
command -bang -nargs=? QFix call QFixToggle(<bang>0)
function! QFixToggle(forced)
if exists("g:qfix_win") && a:forced == 0
cclose
unlet g:qfix_win
else
copen 10
let g:qfix_win = bufnr("$")
endif
endfunction
私の(かなり高度にカスタマイズされた)vimrcはおそらくここに投稿するには長すぎるので、代わりにリンクします。
https://github.com/majutsushi/etc/blob/master/vim/.vimrc
そこにはいくつかの便利な情報があり、自分で書いたものか、役立つと思われるあらゆる種類の情報を含むステータスバーのような場所を見つけました。スクリーンショットは、私が書いたこのプラグインのWebサイトにあります。
私の 。vimrc 、使用するプラグインおよびその他の調整は、最も頻繁に実行するタスクを支援するためにカスタマイズされています。
Vimの設定はこちら についてもっと情報があります
TAB補完なしでは生きられない
" Intelligent tab completion
inoremap <silent> <Tab> <C-r>=<SID>InsertTabWrapper(1)<CR>
inoremap <silent> <S-Tab> <C-r>=<SID>InsertTabWrapper(-1)<CR>
function! <SID>InsertTabWrapper(direction)
let idx = col('.') - 1
let str = getline('.')
if a:direction > 0 && idx >= 2 && str[idx - 1] == ' '
\&& str[idx - 2] =~? '[a-z]'
if &softtabstop && idx % &softtabstop == 0
return "\<BS>\<Tab>\<Tab>"
else
return "\<BS>\<Tab>"
endif
elseif idx == 0 || str[idx - 1] !~? '[a-z]'
return "\<Tab>"
elseif a:direction > 0
return "\<C-p>"
else
return "\<C-n>"
endif
endfunction
~/.vim/after/syntax/vim.vim
ファイルにこれがあります:
それは何ですか:
すなわち:行く場合:
highlight JakeRedKeywords cterm=bold term=bold ctermbg=black ctermfg=Red
赤という言葉は赤になり、黒という言葉は黒になります。
コードは次のとおりです。
syn cluster vimHiCtermColors contains=vimHiCtermColorBlack,vimHiCtermColorBlue,vimHiCtermColorBrown,vimHiCtermColorCyan,vimHiCtermColorDarkBlue,vimHiCtermColorDarkcyan,vimHiCtermColorDarkgray,vimHiCtermColorDarkgreen,vimHiCtermColorDarkgrey,vimHiCtermColorDarkmagenta,vimHiCtermColorDarkred,vimHiCtermColorDarkyellow,vimHiCtermColorGray,vimHiCtermColorGreen,vimHiCtermColorGrey,vimHiCtermColorLightblue,vimHiCtermColorLightcyan,vimHiCtermColorLightgray,vimHiCtermColorLightgreen,vimHiCtermColorLightgrey,vimHiCtermColorLightmagenta,vimHiCtermColorLightred,vimHiCtermColorMagenta,vimHiCtermColorRed,vimHiCtermColorWhite,vimHiCtermColorYellow
syn case ignore
syn keyword vimHiCtermColorYellow yellow contained
syn keyword vimHiCtermColorBlack black contained
syn keyword vimHiCtermColorBlue blue contained
syn keyword vimHiCtermColorBrown brown contained
syn keyword vimHiCtermColorCyan cyan contained
syn keyword vimHiCtermColorDarkBlue darkBlue contained
syn keyword vimHiCtermColorDarkcyan darkcyan contained
syn keyword vimHiCtermColorDarkgray darkgray contained
syn keyword vimHiCtermColorDarkgreen darkgreen contained
syn keyword vimHiCtermColorDarkgrey darkgrey contained
syn keyword vimHiCtermColorDarkmagenta darkmagenta contained
syn keyword vimHiCtermColorDarkred darkred contained
syn keyword vimHiCtermColorDarkyellow darkyellow contained
syn keyword vimHiCtermColorGray gray contained
syn keyword vimHiCtermColorGreen green contained
syn keyword vimHiCtermColorGrey grey contained
syn keyword vimHiCtermColorLightblue lightblue contained
syn keyword vimHiCtermColorLightcyan lightcyan contained
syn keyword vimHiCtermColorLightgray lightgray contained
syn keyword vimHiCtermColorLightgreen lightgreen contained
syn keyword vimHiCtermColorLightgrey lightgrey contained
syn keyword vimHiCtermColorLightmagenta lightmagenta contained
syn keyword vimHiCtermColorLightred lightred contained
syn keyword vimHiCtermColorMagenta Magenta contained
syn keyword vimHiCtermColorRed red contained
syn keyword vimHiCtermColorWhite white contained
syn keyword vimHiCtermColorYellow yellow contained
syn match vimHiCtermFgBg contained "\ccterm[fb]g="he=e-1 nextgroup=vimNumber,@vimHiCtermColors,vimFgBgAttrib,vimHiCtermError
highlight vimHiCtermColorBlack ctermfg=black ctermbg=white
highlight vimHiCtermColorBlue ctermfg=blue
highlight vimHiCtermColorBrown ctermfg=brown
highlight vimHiCtermColorCyan ctermfg=cyan
highlight vimHiCtermColorDarkBlue ctermfg=darkBlue
highlight vimHiCtermColorDarkcyan ctermfg=darkcyan
highlight vimHiCtermColorDarkgray ctermfg=darkgray
highlight vimHiCtermColorDarkgreen ctermfg=darkgreen
highlight vimHiCtermColorDarkgrey ctermfg=darkgrey
highlight vimHiCtermColorDarkmagenta ctermfg=darkmagenta
highlight vimHiCtermColorDarkred ctermfg=darkred
highlight vimHiCtermColorDarkyellow ctermfg=darkyellow
highlight vimHiCtermColorGray ctermfg=gray
highlight vimHiCtermColorGreen ctermfg=green
highlight vimHiCtermColorGrey ctermfg=grey
highlight vimHiCtermColorLightblue ctermfg=lightblue
highlight vimHiCtermColorLightcyan ctermfg=lightcyan
highlight vimHiCtermColorLightgray ctermfg=lightgray
highlight vimHiCtermColorLightgreen ctermfg=lightgreen
highlight vimHiCtermColorLightgrey ctermfg=lightgrey
highlight vimHiCtermColorLightmagenta ctermfg=lightmagenta
highlight vimHiCtermColorLightred ctermfg=lightred
highlight vimHiCtermColorMagenta ctermfg=Magenta
highlight vimHiCtermColorRed ctermfg=red
highlight vimHiCtermColorWhite ctermfg=white
highlight vimHiCtermColorYellow ctermfg=yellow
おそらく以下の最も重要なことは、フォントの選択と配色です。はい、私はそれらのものを楽しくいじくり回しすぎています。 :)
"set tildeop
set nosmartindent
" set guifont=courier
" awesome programming font
" set guifont=peep:h09:cANSI
" another Nice looking font for programming and general use
set guifont=Bitstream_Vera_Sans_MONO:h09:cANSI
set lines=68
set tabstop=2
set shiftwidth=2
set expandtab
set ignorecase
set nobackup
" set writebackup
" Some of my favourite colour schemes, lovingly crafted over the years :)
" very dark scarlet background, almost white text
" hi Normal guifg=#FFFFF0 guibg=#3F0000 ctermfg=white ctermbg=Black
" C64 colours
"hi Normal guifg=#8CA1EC guibg=#372DB4 ctermfg=white ctermbg=Black
" Nice forest green background with bisque fg
hi Normal guifg=#9CfCb1 guibg=#279A1D ctermfg=white ctermbg=Black
" dark green background with almost white text
"hi Normal guifg=#FFFFF0 guibg=#003F00 ctermfg=white ctermbg=Black
" french blue background, almost white text
"hi Normal guifg=#FFFFF0 guibg=#00003F ctermfg=white ctermbg=Black
" slate blue bg, grey text
"hi Normal guifg=#929Cb1 guibg=#20403F ctermfg=white ctermbg=Black
" yellow/orange bg, black text
hi Normal guifg=#000000 guibg=#f8db3a ctermfg=white ctermbg=Black