文章目录
  1. 1. 2015-5-20
    1. 1.1. pipe content from console output to vim
    2. 1.2. shortcut to exit vim
    3. 1.3. Highlight changes in unified diff
  2. 2. 2016-5-19
    1. 2.1. Count number of matches of a pattern
  3. 3. 2016-5-10
    1. 3.1. color scheme in Vim in ConEmu not work
    2. 3.2. multiple condition in Vim
    3. 3.3. switch case of letter
  4. 4. 2016-5-3
    1. 4.1. Perform same operation across buffers
  5. 5. 2016-4-29
    1. 5.1. Pick the first spell suggestion
  6. 6. 2016-4-25
    1. 6.1. use .vim folder in windows
    2. 6.2. convert VimWiki to markdown using Vim
    3. 6.3. vim non-greedy search
  7. 7. 2016-4-22
    1. 7.1. go back end of word (go to end of previous word)
  8. 8. 2016-4-21
    1. 8.1. gf with auto file extension, especially in wiki markdown
  9. 9. 2016-4-20
    1. 9.1. Voom plugin with error: python’s site module could not be loaded
  10. 10. No Answer Questions
    1. 10.1. Convert Space Separated to CamelCase

2015-5-20

pipe content from console output to vim

vim -, eg: ls -la | vim -

shortcut to exit vim

  • ZZ save and exit
  • ZQ exit without save

Highlight changes in unified diff

  1. copy diff.vim from installation location to your own customizable location.
  2. modify diff.vim like following:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/syntax/diff.vim b/syntax/diff.vim
--- a/syntax/diff.vim
+++ b/syntax/diff.vim
@@ -366,9 +366,9 @@ hi def link diffBDiffer Constant
hi def link diffIsA Constant
hi def link diffNoEOL Constant
hi def link diffCommon Constant
-hi def link diffRemoved Special
+hi def link diffRemoved Error
hi def link diffChanged PreProc
-hi def link diffAdded Identifier
+hi def link diffAdded Todo
hi def link diffLine Statement
hi def link diffSubname PreProc
hi def link diffComment Comment

2016-5-19

Count number of matches of a pattern

To count the number of matches of a pattern, use the substitute command with the n flag. The following shows the number of times that pattern matches text in the current buffer:

1
:%s/pattern//gn

Omit g to display the number of lines where the pattern matches:

1
:%s/pattern//n

Link

2016-5-10

color scheme in Vim in ConEmu not work

  1. follow guide
  2. rename/remove /bin/vim from git bash which is not supported.

multiple condition in Vim

&&, tip: help expr

switch case of letter

~ in visual mode

2016-5-3

Perform same operation across buffers

  1. store operation in macro a
  2. [OPTIONAL] set nomore to avoid interruption during processing
  3. :bufdo execute "norma! @a" | update

2016-4-29

Pick the first spell suggestion

1z=

2016-4-25

use .vim folder in windows

Add following lines to vimrc:

1
2
3
if has('win32') || has('win64')
set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
endif

Link

convert VimWiki to markdown using Vim

1
2
3
4
5
6
7
8
9
10
* Convert bold: %s/\*\(.*\)\*/**\1**/g
* Convert named link: %s/\[\[\(.\{-}\)|\(.\{-}\)\]\]/[\2](\1)/g
* Convert link: %s/\[\[\(.\{-}\)\]\]/<\1>/g
* Title:
* First: %s/= \(.*\) =/# \1/g
* May multiple: %s/=\(.*\)=/#\1/g
* Picture: %s/{{\(.\{-}\)}}/![](\1)/g
* Fenced code start: %s/{{{class="brush:\(.*\)"/```\1/g
* Fenced code end: %s/}}}/```/g
* Manual change # ordered list

The non-greedy version of * is \{-}. So, simply replace .* with .\{-

Link

2016-4-22

go back end of word (go to end of previous word)

Use ge

2016-4-21

gf with auto file extension, especially in wiki markdown

Put following in vimrc

1
autocmd FileType markdown setlocal suffixesadd=.md,.markdown

2016-4-20

Voom plugin with error: python’s site module could not be loaded

Due to bug of Python 2.7.11, workaround:

  1. Install other version.
  2. after install execute following command (of course, need admin privilege). refer to Link
    1
    2
    reg copy HKLM\SOFTWARE\Python\PythonCore\2.7 HKLM\SOFTWARE\Python\PythonCore\2.7-32 /s /reg:32
    reg copy HKLM\SOFTWARE\Python\PythonCore\2.7 HKLM\SOFTWARE\Python\PythonCore\2.7-32 /s /reg:64

No Answer Questions

Convert Space Separated to CamelCase

No answer.

文章目录
  1. 1. 2015-5-20
    1. 1.1. pipe content from console output to vim
    2. 1.2. shortcut to exit vim
    3. 1.3. Highlight changes in unified diff
  2. 2. 2016-5-19
    1. 2.1. Count number of matches of a pattern
  3. 3. 2016-5-10
    1. 3.1. color scheme in Vim in ConEmu not work
    2. 3.2. multiple condition in Vim
    3. 3.3. switch case of letter
  4. 4. 2016-5-3
    1. 4.1. Perform same operation across buffers
  5. 5. 2016-4-29
    1. 5.1. Pick the first spell suggestion
  6. 6. 2016-4-25
    1. 6.1. use .vim folder in windows
    2. 6.2. convert VimWiki to markdown using Vim
    3. 6.3. vim non-greedy search
  7. 7. 2016-4-22
    1. 7.1. go back end of word (go to end of previous word)
  8. 8. 2016-4-21
    1. 8.1. gf with auto file extension, especially in wiki markdown
  9. 9. 2016-4-20
    1. 9.1. Voom plugin with error: python’s site module could not be loaded
  10. 10. No Answer Questions
    1. 10.1. Convert Space Separated to CamelCase