Skip to content

Instantly share code, notes, and snippets.

@kkedf
Last active October 25, 2018 11:52
Show Gist options
  • Save kkedf/65bdff53c5f390cb06f1194d94fe89eb to your computer and use it in GitHub Desktop.
Save kkedf/65bdff53c5f390cb06f1194d94fe89eb to your computer and use it in GitHub Desktop.
vim notes
http://www.vim.org/scripts/script.php?script_id=521
--mru.vim : Plugin to manage Most Recently Used (MRU) files
http://www.thegeekstuff.com/2009/08/vim-editor-how-to-setup-most-recently-used-documents-features-using-mru-plugin/
http://www.vim.org/scripts/script.php?script_id=1658
--The NERD tree : A tree explorer plugin for navigating the filesystem
http://thehumblecoder.wordpress.com/2006/08/08/vim-swap-and-backup-files/
http://www.study-area.org/tips/vim/Vim-9.html
vim config
--set t_Co=256
--colorscheme zenburn
--set ruler
--set number
--set ch=2
--set backup
--set backupext=.bak
--set incsearch
--set ic
--map <F2> :NERDTreeToggle<CR>
--map <F3> :MRU<CR>
vim color scheme zenburn
--http://slinky.imukuppi.org/zenburn/
--http://www.vim.org/scripts/script.php?script_id=415
http://blog.superbil.info/2009/08/vimrc.html
http://blog.roga.tw/2010/01/%E6%88%91%E7%9B%AE%E5%89%8D%E4%BD%BF%E7%94%A8%E7%9A%84-vimrc-%E8%A8%AD%E5%AE%9A%E6%AA%94/
http://blog.vgod.tw/2009/12/08/vim-cheat-sheet-for-programmers/
http://www.yolinux.com/TUTORIALS/LinuxTutorialAdvanced_vi.html
ctrl-] The vim editor will jump into the tag to follow it to a new position in the file or to a new file.
ctrl-t The vim editor will allow the user to jump back a level.
http://vim.wikia.com/wiki/Browsing_programs_with_tags
Vim will search for the file named 'tags', starting with the directory of the current file and then going to the parent directory and then recursively to the directory one level above, till it either locates the 'tags' file or reaches the root directory
:set tags=./tags;
vim + ctags
http://blog.sina.com.cn/s/blog_498a6eeb0100b1cy.html
http://descent-incoming.blogspot.com/2008/03/vim-ctag-ctag.html
http://blog.yam.com/kikakika/article/27459014
http://blog.yam.com/kikakika/article/27458895
http://blog.yam.com/kikakika/article/26867424
http://stenlyho.blogspot.com/2008/11/ubuntuvim-plugin-ctagstaglist.html
http://adrianhuang.blogspot.com/2007/09/trace-code-gvimctagscscope.html
ctags -R
VIM + bufexplorer
http://blog.cathayan.org/item/1204
http://have2look.com/wordpress/archives/52.html
http://www.vim.org/scripts/script.php?script_id=42
http://groups.google.com/group/vim-taiwan/browse_thread/thread/91f2727c20d6c4b3?pli=1
http://lorenlai.pixnet.net/blog/post/30682573
http://tc.wangchao.net.cn/bbs/detail_1631832.html
http://moto.debian.org.tw/viewtopic.php?t=1061
VIM + Taglist
http://c9s.blogspot.com/2007/07/vim-taglist-plugin.html
http://nixchun.pixnet.net/blog/post/21765036
http://blog.elleryq.idv.tw/2006/05/vimtaglist.html
http://www.vim.org/scripts/script.php?script_id=273
http://vim.wikia.com/wiki/Browsing_programs_with_tags
http://vim.1045645.n5.nabble.com/vim-can-t-use-paths-in-tags-file-exuberant-ctags-win-xp-on-c-td1189693.html
http://rickey-nctu.blogspot.com/2009/02/vim-srcexpl.html
http://vim-taglist.sourceforge.net/faq.html
http://stackoverflow.com/questions/563616/vim-and-ctags-tips-and-tricks
http://community.ingres.com/wiki/Vim_and_ctags
[article] 最佳vim技巧
http://moto.debian.org.tw/viewtopic.php?t=1061
vim 大小寫轉換
http://www.csie.nctu.edu.tw/~chlo/web/docs/doc/data/vim/13.htm
vim 7.0的新功能 - 分頁(tab)
http://www.javaworld.com.tw/roller/snpshu/entry/2006_11_3_vim_tabs
http://www.linux.com/archive/feed/59533
http://www.techrepublic.com/blog/opensource/use-tabs-to-open-multiple-files-in-vim/678
gvim
http://c9s.blogspot.com/2007/06/gvim.html
Enhanced gVim Package for Win32
http://c9s.blogspot.com/2007/09/enhanced-gvim-package-for-win32.html
http://www.microsoft.com/downloads/en/details.aspx?familyid=22e69ae4-7e40-4807-8a86-b3d36fab68d3&displaylang=en
Overview
Consolas is intended for use in programming environments and other circumstances where a monospaced font is specified. All characters have the same width, like old typewriters, making it a good choice for personal and business correspondence. Optimizing the font specifically for ClearType allowed a design with proportions closer to normal text than traditional monospaced fonts like Courier. This allows for more comfortable reading of extended text on-screen.
The package will change the default text face in Visual Studio to the Consolas family.
This package is only intended for licensed users of Microsoft Visual Studio 2005 or 2008.
vim ref http link
http://yyq123.blogspot.com/
http://www.study-area.org/tips/vim/index.html
[筆記] Linux.find+grep.screen.vimdiff + vi 設定檔+Visual block
--http://liwecan.pixnet.net/blog/post/28306253
vimdiff
--http://c9s.blogspot.com/2007/08/vimdiff.html
http://ninitsai0206.blogspot.com/2010/12/using-diff-on-vim.html
http://vim.dindinx.net/vim7/html/diff.txt.php
垂直比對
:vert diffsplit {filename}
更新diff status
:diffupdate
垂直比對_other1
1. open file 1
1.1 :diffthis
2. :vsplit OR :vnew
3. open file 1
3.1 :diffthis
垂直比對_other2
vimdiff file1 file2
多視窗(:vsplit, split)關閉
:qall
http://trac.nchc.org.tw/grid/attachment/wiki/gpxe-sis900/08-02-12_VIMDIFF_UTF8.txt
:diffget :diffput 將左右兩邊的差異互拷
do, dp short hotkey
windows vim config
" windows version vim config file
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction
" up config is from vim 7.3 windows version
set t_Co=256
colorscheme zenburn
set ruler
set number
set ch=2
set backup
set backupext=.bak
set incsearch
set ic
set guifont=Monaco:h12
" vim + ctags config ref http://blogold.chinaunix.net/u3/111185/showart_2270485.html
" http://vim.wikia.com/wiki/Browsing_programs_with_tags
" search parent directory for tags file
set tags=tags;
set autochdir
map <F2> :NERDTreeToggle<CR>
map <F3> :MRU<CR>
map <F4> :TlistToggle<CR>
http://freehaha.blogspot.com/2008/02/vim-buffer-tab.html
vim buffer->tab
:tab ball
http://www.rayninfo.co.uk/vimtips.html
Best of Vim Tips
----------------------------------------
" Absolutely essential
----------------------------------------
* # g* g# : find word under cursor (<cword>) (forwards/backwards)
% : match brackets {}[]()
. : repeat last modification
@: : repeat last : command (then @@)
matchit.vim : % now matches tags <tr><td><script> <?php etc
<C-N><C-P> : word completion in insert mode
<C-X><C-L> : Line complete SUPER USEFUL
/<C-R><C-W> : Pull <cword> onto search/command line
/<C-R><C-A> : Pull <CWORD> onto search/command line
:set ignorecase : you nearly always want this
:set smartcase : overrides ignorecase if uppercase used in search string (cool)
:syntax on : colour syntax in Perl,HTML,PHP etc
:set syntax=perl : force syntax (usually taken from file extension)
:h regexp<C-D> : type control-D and get a list all help topics containing
regexp (plus use TAB to Step thru list)
::show current edit file name and path
http://groups.google.com/group/comp.editors/browse_thread/thread/85e969ca3651da80
But how can I see the full path of the file I am currently editing?
:echo expand('%:p')
-----
vim grep (search keyword)
-- :lv or :lvimgrep
----http://vim.wikia.com/wiki/Find_in_files_within_Vim
----http://jeffblack360.wordpress.com/2011/02/04/vim-lvimgrep-is-a-beautiful-thing/
----http://vim.1045645.n5.nabble.com/vimgrep-vs-lvimgrep-td1164116.html
----
回到上一次的遊標位置 Ctrl+o
http://stackoverflow.com/questions/5052079/move-cursor-to-its-last-position
http://stackoverflow.com/questions/53911/in-vim-how-do-i-go-back-to-where-i-was-before-a-search
--
http://vim.wikia.com/wiki/Count_number_of_matches_of_a_pattern
:%s/pattern//gn
This makes it easy to count the number of occurrences of the word under the cursor: first press * to search for the current word, then enter :%s///gn to count all occurrences of that word.
https://stackoverflow.com/questions/5288875/how-to-expand-collapse-a-diff-sections-in-vimdiff
Keyboard Shortcuts:
d o Get changes from other window into the current window.
d p Put the changes from current window into the other window.
] c Jump to the next change.
[ c Jump to the previous change.
CTRL+W, w - Switch to the other split window
(CTRL+W, CTRL+W does the same thing, in case you let go of the CTRL key a bit later)
:diffupdate :diffu -> recalculate the diff, useful when after making several changes vim's isn't showing minimal changes anymore. Note that it only works if the files have been modified inside vimdiff. Otherwise, use:
:e to reload the files if they have been modified outside of vimdiff.
:set noscrollbind -> temporarily disable simultaneous scrolling on both buffers, reenable by
:set scrollbind and scrolling.
Most of what you asked for is folding: vim user manual's chapter on folding. Outside of diffs I sometime use:
zo -> open fold. 或是按方向右鍵
zc -> close fold.
But you'll probably be better served by:
zr -> reducing folding level.
zm -> one more folding level, please.
or even:
zR -> Reduce completely the folding, I said!.
zM -> fold Most!.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment