1 "" Let's start VIM journey 2 set nocompatible 3 4 "" Include default settings 5 "source $VIMRUNTIME/vimrc_example.vim 6 "source $VIMRUNTIME/gvimrc_example.vim 7 8 "" shell settings 9 let $PATH="$HOME/bin;C:/msys64/usr/bin;C:/msys64/mingw64/bin;C:/Windows;C:/Windows/System32" 10 set shell=bash.exe 11 set shellslash 12 13 "" Don't need ugly files 14 set backupdir=c:/temp/vim/backup 15 set directory=c:/temp/vim/swap 16 set nobackup 17 set swapfile 18 set undodir=c:/temp/vim/undo 19 set undofile 20 set writebackup 21 22 "" UI settings 23 set cmdheight=2 24 "set guioptions-=t 25 set laststatus=2 26 set lazyredraw 27 set lines=35 columns=160 28 set number 29 set renderoptions=type:directx 30 set ruler 31 set showcmd 32 set wildmenu 33 34 "colorscheme torte 35 colorscheme koehler 36 37 "" Tab/Space related 38 set expandtab 39 set shiftwidth=4 40 set softtabstop=4 41 set tabstop=4 42 43 "" IME settings 44 if has("multi_byte") 45 set encoding=utf-8 46 "let &termencoding = &encoding 47 set termencoding=unicode 48 " Set default encoding as UTF-8 with BOM 49 setglobal fileencoding=utf-8 "bomb "bomb introduce problem for *nix 50 set fileencodings=ucs-bom,utf-8,gb18030,cp936,cp950,latin1 51 " Walkaround the encoding problem for fenc=utf-8 && enc=ucs-2 52 augroup i18n 53 autocmd! 54 autocmd BufReadPost * if &fileencoding == "utf-8" | let &encoding = &fileencoding | endif 55 augroup END 56 endif 57 58 "" Enable the Chinese characters 59 "set guifont=Fira_Code:h11:cANSI,NSimSun:h12:cGB2312 60 set guifont=Iosevka:h12:cANSI:qDRAFT ",SimHei:h12:cGB2312:qDRAFT 61 "set guifontwide=SimHei:h12:cGB2312 62 "set guifontwide=Microsoft_YaHei:h12:cGB2312 63 set guifontwide=Noto_Mono:h12:cGB2312 64 65 "" IME 66 if has('multi_byte_ime') 67 "未开启IME时光标背景色 68 hi Cursor guifg=bg guibg=Orange gui=NONE 69 "开启IME时光标背景色 70 hi CursorIM guifg=NONE guibg=Skyblue gui=NONE 71 " 关闭Vim的自动切换IME输入法(插入模式和检索模式) 72 set iminsert=0 imsearch=0 73 " 插入模式输入法状态未被记录时,默认关闭IME 74 inoremap <silent> <ESC> <ESC>:set iminsert=0<CR> 75 endif 76 77 "" Useful Plugins 78 packadd vim-fugitive 79 "" Plugin - airline 80 let g:airline_theme='solarized' 81 let g:airline_detect_iminsert=1 82 let g:airline_highlighting_cache = 1 83 let g:airline_powerline_fonts = 1 84 let g:airline#extensions#tabline#enabled = 1 85 packadd vim-airline 86 packadd vim-airline-themes 87 88 "" Plugins 89 packadd! emmet-vim 90 packadd! ctrlp.vim 91 packadd! nerdtree 92 93 "" Key Maps 94 "" display the syntax name under the cursor 95 map <F12> :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "name")<CR> 96 "" We can navigate the list by using the <F3> and <S-F3> 97 map <F3> :cnext<CR> 98 map <S-F3> :cprevious<CR> 99 "" Let's help the tab navigation a little 100 map <F4> :try\|:next\|finish\|catch\|:tabnext\|endtry<CR> 101 map <S-F4> :bdelete<CR> 102 "" Tlist and NERDTree 103 map <F5> :NERDTreeToggle<CR> 104 map <S-F5> :Tlist<CR> 105 set tags=./tags,../tags,../../tags,../../../tags 106 "" open Terminal 107 tmap <F9> <C-W>:$tabnew +:term<CR><C-W>o 108 map <F9> :$tabnew +:term<CR><C-W>o 109 110
2018/09/03
vimrc 备份
2017/04/13
Emmet for Vim
Emmet for Vim - 用 Vim 开发 HTML CSS 前端的必备工具。 大幅度提高生产效率。
缺省的展开键是:
缺省的展开键是:
先按 CTRL-y 再按 ,
当然也可以通过修改: 自行修改为 CTRL-e 或者 指定其他按键!let g:user_emmet_expandabbr_key = ''
2009/09/02
VIM Wiki
非常不错的网站 介绍了很多VIM的技巧。今天用到了一个小技巧,如何在VIM内排序。在VIM7.0
这个非常简单,可以直接使用内置的`:sort' 命令。当然,还可以剔除重复的 `:sort u'.
这个非常简单,可以直接使用内置的`:sort' 命令。当然,还可以剔除重复的 `:sort u'.
2009/08/13
VIM unicode
在 MS Windows 下面由于受 Byte Order Mark (BOM) 的控制, 需要对GVIM 做一些配置才能正常工作。 这包括 tenc, enc, fencs, guifont, guifontwide。 这样一来,vim就可以自动 根据BOM做出正确的显示了,同时也可以自动识别GBK和BIG5。
if has("multi_byte")
set encoding=unicode
let &termencoding = &encoding
" Set default encoding as UTF-8 with BOM
setglobal fileencoding=utf-8 bomb
" Auto detect the file encoding BOM unicode, utf-8, GBK, Big5, Latin1
set fileencodings=ucs-bom,utf-8,cp936,cp950,latin1
" Walkaround the encoding problem for fenc=utf-8 && enc=ucs-2
augroup i18n
autocmd!
autocmd BufReadPost * if &fileencoding == "utf-8" | let &encoding = &fileencoding | endif
augroup END
endif
" Enable the Chinese characters
"set guifont=Bitstream\ Vera\ Sans\ Mono:h10:cANSI,NSimSun:h11:cGB2312
set guifont=Consolas:h11:cANSI,NSimSun:h11:cGB2312
set guifontwide=NSimSun:h11:cGB2312
2009/04/22
VIMRC file
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/gvimrc_example.vim
set nobackup
set ch=1
set tabstop=4
set shiftwidth=4
"set softtabstop=4
set expandtab
colorscheme darkblue
"colorscheme oceandeep
" Enable the Chinese characters
set guifont=Bitstream\ Vera\ Sans\ Mono:h10:cANSI,NSimSun:h12:cGB2312
set guifontwide=NSimSun:h12:cGB2312
" display the syntax name under the cursor
map <F12> :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "name")<CR>
" We can navigate the list by using the <F3> and <S-F3>
map <F3> :cnext<CR>
map <S-F3> :cprevious<CR>
" Let's help the tab navigation a little
map <F9> :tabprevious<CR>
map <S-F9> :tabnext<CR>
" Tlist
map <F5> :Tlist<CR>
set tags=./tags,../tags,../../tags
2008/12/18
VIM is so cool
VIM is really cool, you can increase/decrease a number in the text directly by with CTRL-A and CTRL-X!
Adding and subtracting
*CTRL-A*
CTRL-A Add [count] to the number or alphabetic character at
or after the cursor. {not in Vi}
*CTRL-X*
CTRL-X Subtract [count] from the number or alphabetic
character at or after the cursor. {not in Vi}
The CTRL-A and CTRL-X commands work for (signed) decimal numbers, unsigned
octal and hexadecimal numbers and alphabetic characters. This depends on the
'nrformats' option.
- When 'nrformats' includes "alpha", Vim will change the alphabetic character
under or after the cursor. This is useful to make lists with an alphabetic
index.
- When 'nrformats' includes "hex", Vim assumes numbers starting with '0x' or
'0X' are hexadecimal. The case of the rightmost letter in the number
determines the case of the resulting hexadecimal number. If there is no
letter in the current number, Vim uses the previously detected case.
- When 'nrformats' includes "octal", Vim considers numbers starting with a '0'
to be octal. Other numbers are decimal and may have a preceding minus sign.
If the cursor is on a number, the commands apply to that number; otherwise
Vim uses the number to the right of the cursor.
For numbers with leading zeros (including all octal and hexadecimal numbers),
Vim preserves the number of characters in the number when possible. CTRL-A on
"0077" results in "0100", CTRL-X on "0x100" results in "0x0ff". Note that
when 'nrformats' includes "octal", decimal numbers with leading zeros are
impossible because they are indistinguishable from octal numbers.
The CTRL-A command is very useful in a macro. Example: Use the following
steps to make a numbered list.
1. Create the first list entry, make sure it starts with a number.
2. qa - start recording into buffer 'a'
3. Y - yank the entry
4. p - put a copy of the entry below the first one
5. CTRL-A - increment the number
6. q - stop recording
7.@a - repeat the yank, put and increment times
2008/12/11
copy and paste in VIM
VIM have multiple clipboard which allows you copy and save different content at the same time. The register can be any of {a-zA-Z0-9.%#:-"}. It is really interesting thing which I never notice before.
I forgot there is another register *, it is as same as the system clipboard. So you can yank some text into register *, it will be in the system clipboard also. :D"{a-zA-Z0-9.%#:-"} Use register {a-zA-Z0-9.%#:-"} for next delete, yank
or put (use uppercase character to append with
delete and yank) ({.%#:} only work with put).
:reg[isters] Display the contents of all numbered and named
registers. {not in Vi}
:reg[isters] {arg} Display the contents of the numbered and named
registers that are mentioned in {arg}. For example:
["x]y{motion} Yank {motion} text [into register x]. When no
characters are to be yanked (e.g., "y0" in column 1),
this is an error when 'cpoptions' includes the 'E'
flag.
["x]p Put the text [from register x] after the cursor
[count] times. {Vi: no count}
2008/09/26
VIM Tips
I am running in a English version Windows XP in office. The default encoding of the OS is english! While I still want to be able to work with some Chinese document in VIM, how can I make it happen?
That's simple, put this line into your vimrc file
And "Bitstream Vera Sans Mono" to be used for ANSI characters.
Indeed this option can be set locally for each individual files by using the VIM modeline
VIM is fantastic cool~~~
That's simple, put this line into your vimrc file
set guifont=Bitstream\ Vera\ Sans\ Mono:h10:cANSIVIM will be using NSimSun to display the Chinese characters. :)
set guifontwide=NSimSun:h11:cGB2312
And "Bitstream Vera Sans Mono" to be used for ANSI characters.
Indeed this option can be set locally for each individual files by using the VIM modeline
vim:ts=4:sw=4:expandtab:enc=utf8All the VIM option can be changed locally. Don't forget to put this modeline into the comments :D
VIM is fantastic cool~~~
2008/05/13
Using :vimgrep inside VIM
Grep is really power tool under the UNIX domain. From Vim 7, an internal `grep` was provided by Vim.
Using `:vimgrep` is fairly easy, just in command mode, type in
Let's do something to help us! Put this into your ~/.vimrc file.
After that, you will be able to use the <F3> and <shift>-<F3> navigate the `quickfix` list easily. :D
Using `:vimgrep` is fairly easy, just in command mode, type in
:vim[grep][!] /{pattern}/[g][j] {file} ...The `grep` result will be put into the `quickfix` list. The `:cnext`, and `:cprevious` can be used to navigate the `quickfix` list.
Let's do something to help us! Put this into your ~/.vimrc file.
" We can navigate the list by using theand
map <F3> :cnext
map <S-F3> :cprevious
After that, you will be able to use the <F3> and <shift>-<F3> navigate the `quickfix` list easily. :D
2008/05/09
Tip for trouble shooting the VIM syntax highlight
It is easy to do a VIM syntax highlight file, while it is a little difficult for you to do the trouble shooting, especially when you do a recursive pattern match with `contains`, `nextgroup` keywords.
Here is a small tip can help you a little bit.
put this into your ".vimrc" file
For the next time, when you met some syntax highlight error, you can key in <F12> at the error place, VIM will tell you "what kind syntax ID that it is thing under the given position".
Keep fun! :)
Here is a small tip can help you a little bit.
put this into your ".vimrc" file
" display the syntax name under the cursor
map <F12> :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "name")
For the next time, when you met some syntax highlight error, you can key in <F12> at the error place, VIM will tell you "what kind syntax ID that it is thing under the given position".
Keep fun! :)
2007/01/30
VIM syntax for JavaScript 0.7.2 released
Today I do update the JavaScript syntax script for VIM to 0.7.2.
Until now PRC 2007.01.30-21:37 my script got:
Rating 332/99, Downloaded by 1684
I do like more feature, but I like the accuracy much more. :D
Without the context based parser, it can't highlight the JavaScript properly.
Until now PRC 2007.01.30-21:37 my script got:
Rating 332/99, Downloaded by 1684
I do like more feature, but I like the accuracy much more. :D
Without the context based parser, it can't highlight the JavaScript properly.
2006/10/23
keepend instruction in VIM syntax file
In the VIM "syntax region" instruction, there is a special parameter "keepend". In the VIM tutorial, the given sample is a inline comments. Somehow it give me a misleading that the *keepend* will be only used to match the end of line '$'. While it's totally wrong. :(
在VIM的 "syntax region" 语法中,支持一个特殊的 "keepend" 参数。 在 VIM 的介绍中, 对 keepend 用法的介绍是通过一个行内注释,以及可以在注释内出现的语法来讲解的。因此我已开始对 keepend 的用法也产生了错觉,认为它就是用来匹配行尾 "$" 的。但是实际上,这样的认识是完全错误的。
Let's take a look at this example.
if the "keepend" is defined in xBlock, the follows messge will be highlighted in wrong way.
The xBlock will be terminated at the "}" inside the xDocComment. Even the the first "{" are matched as xDocLink, the "}" is still consided as the end of xBlock. It is the side effect of "keepend" instruction of xBlock.
The really meanings of "keepend" is to match the end of region, even it has already matched with its nested regions, whatever what's the pattern of end, in most case, it is "$", but it can be anything there.
其实 "keepend" 语句的实际意义是:尽可能匹配 region 所指定的 end pattern, 即便 这个pattern实际上已经被它的内联region所匹配了。这里的 keepend 实际上是指 end pattern,而不管这个 pattern 到底是什么,尽管大多数时候它都是 "$"。
在VIM的 "syntax region" 语法中,支持一个特殊的 "keepend" 参数。 在 VIM 的介绍中, 对 keepend 用法的介绍是通过一个行内注释,以及可以在注释内出现的语法来讲解的。因此我已开始对 keepend 的用法也产生了错觉,认为它就是用来匹配行尾 "$" 的。但是实际上,这样的认识是完全错误的。
Let's take a look at this example.
syntax region xDocLink start="{" end="}" contained
syntax region xDocComment start="/\*\*" end="\*/"
\ contains=xDocLink
syntax region xBlock start="{" end="}"
\ contains=xDocComment keepend
if the "keepend" is defined in xBlock, the follows messge will be highlighted in wrong way.
{
/**
* The comments {@links}
*/
Block;
}
The xBlock will be terminated at the "}" inside the xDocComment. Even the the first "{" are matched as xDocLink, the "}" is still consided as the end of xBlock. It is the side effect of "keepend" instruction of xBlock.
The really meanings of "keepend" is to match the end of region, even it has already matched with its nested regions, whatever what's the pattern of end, in most case, it is "$", but it can be anything there.
其实 "keepend" 语句的实际意义是:尽可能匹配 region 所指定的 end pattern, 即便 这个pattern实际上已经被它的内联region所匹配了。这里的 keepend 实际上是指 end pattern,而不管这个 pattern 到底是什么,尽管大多数时候它都是 "$"。
Search pattern in VIM
The search pattern of VIM is little different with Perl. There is one thing I igonred at the beginning, and it made me confused for a long time. That is the group pattern can't be used inside the "[]"
In http://vimdoc.sourceforge.net/htmldoc/usr_27.html#27.6
But they can't be used inside the "[]" .
:-)
In http://vimdoc.sourceforge.net/htmldoc/usr_27.html#27.6
item matches equivalentUsing this predefined ranges works a lot faster than the character range it stands for.
\d digit [0-9]
\D non-digit [^0-9]
\x hex digit [0-9a-fA-F]
\X non-hex digit [^0-9a-fA-F]
\s white space [ ] (and )
\S non-white characters [^ ] (notand )
\l lowercase alpha [a-z]
\L non-lowercase alpha [^a-z]
\u uppercase alpha [A-Z]
\U non-uppercase alpha [^A-Z]
But they can't be used inside the "[]" .
:-)
2006/10/18
VIM JavaScript syntax updated to 0.6
We have been there 0.5.1 for some monthes. Today, we will move to 0.6 :) The mainly changed part is JSDoc introduction.
The syntax file has been downloaded by 1019, it's rating 256/77 at 2006-10-17.
It is the 4th rated syntax file at VIM site. Please vote me, if it is helpful :)
I hope it can come into the offical VIM package in the near later.
The syntax file has been downloaded by 1019, it's rating 256/77 at 2006-10-17.
It is the 4th rated syntax file at VIM site. Please vote me, if it is helpful :)
I hope it can come into the offical VIM package in the near later.
2006/10/14
VIM syntax for JavaScript
This is my first VIM syntax file. Personaly, I think it is better than the Javascript syntax packaged with the VIMRUNTIME packages. Original version from Claudio Fleiner.
这是我制作的第一个 VIM syntax 文件, 其实也是在 Claudio Fleiner 原有的版本上改进而来的。自我感觉这个 syntax 比 VIM 发行版中自带的要好。:D 是不是有点自我吹捧了 xixi
It supports these lexcial elements in JavaScript: 可以识别的 JavaScript 语法类型:
这是我制作的第一个 VIM syntax 文件, 其实也是在 Claudio Fleiner 原有的版本上改进而来的。自我感觉这个 syntax 比 VIM 发行版中自带的要好。:D 是不是有点自我吹捧了 xixi
It supports these lexcial elements in JavaScript: 可以识别的 JavaScript 语法类型:
- String in "" or '';
- Regex string
- Number
- Code comments in C/C++ style
- TODO FIXME XXX TBD hightlight in the comments
- JavaScript keywords
- Global Ojbects: Array Boolean Date Error Function java JavaArray JavaClass JavaObject JavaPackage Math netscape Number Object Packages RegExp String
- Bracket matches, including '{} [] ()'
订阅:
博文 (Atom)
BlockChain 相关电子书
@copyright of Sam Chadwick - https://thehub.thomsonreuters.com/groups/bitcoin/blog/2017/09/10/blockchain-paper Blockchain Papers A c...
-
为Windows 10 添加 拼音加加双拼 输入方案 把下面的内容保存为 ppp.reg, 然后双击导入注册表,Pinyin PlusPlus双拼输入方案就有了。 Windows Registry Editor Version 5.00 [HKEY_CURRENT...
-
算起来到这里已经一年多了, 中间断断续续当然了也包括一些可观的原因,一共也没有放多少东西上来。 总算还有两片篇幅较长的原创,也算是聊以自慰了。 再接再厉好了!希望自己能够百尺竿头更进一步~~~
-
Today I do update the JavaScript syntax script for VIM to 0.7.2. Until now PRC 2007.01.30-21:37 my script got: Rating 332/99, Downloaded by ...