mirror of
https://github.com/ViViDboarder/vim-settings.git
synced 2024-11-17 19:26:27 +00:00
Switched to vundle
This commit is contained in:
parent
2438806eea
commit
48336345ab
@ -3,6 +3,15 @@
|
||||
# Get current directory for future use in links
|
||||
VIM_SYNC_DIR=${PWD}
|
||||
|
||||
# Clone vundle
|
||||
mkdir -p ~/.vim/bundle
|
||||
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
|
||||
|
||||
# Make backup and tmp dirs
|
||||
mkdir -p ~/.vim/backup
|
||||
mkdir -p ~/.vim/tmp
|
||||
mkdir -p ~/.vim/doc
|
||||
|
||||
# If a .vimrc_sync doesn't exist, link it
|
||||
if [[ ! ( -f ~/.vimrc_sync ) ]]; then
|
||||
ln -s $VIM_SYNC_DIR/vim/dot_vimrc ~/.vimrc_sync
|
||||
@ -31,8 +40,11 @@ if ! ( grep -q 'set runtimepath+=$HOME/.vim_sync' ~/.vimrc ); then
|
||||
echo 'set runtimepath+=$HOME/.vim_sync' >> ~/.vimrc
|
||||
fi
|
||||
|
||||
# Install all bundles
|
||||
vim +BundleInstall! +qall
|
||||
|
||||
# Execute vim's update of the helptags
|
||||
vim +"helptags ~/.vim_sync/doc" +"q"
|
||||
vim +"helptags ~/.vim/doc" +"q"
|
||||
|
||||
echo "Should install ctags with sudo apt-get install ctags"
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,191 +0,0 @@
|
||||
" Vim color scheme
|
||||
" Name: vividchalk.vim
|
||||
" Author: Tim Pope <vimNOSPAM@tpope.info>
|
||||
" Version: 2.0
|
||||
" GetLatestVimScripts: 1891 1 :AutoInstall: vividchalk.vim
|
||||
|
||||
" Based on the Vibrank Ink theme for TextMate
|
||||
" Distributable under the same terms as Vim itself (see :help license)
|
||||
|
||||
if has("gui_running")
|
||||
set background=dark
|
||||
endif
|
||||
hi clear
|
||||
if exists("syntax_on")
|
||||
syntax reset
|
||||
endif
|
||||
|
||||
let colors_name = "vividchalk"
|
||||
|
||||
" First two functions adapted from inkpot.vim
|
||||
|
||||
" map a urxvt cube number to an xterm-256 cube number
|
||||
fun! s:M(a)
|
||||
return strpart("0245", a:a, 1) + 0
|
||||
endfun
|
||||
|
||||
" map a urxvt colour to an xterm-256 colour
|
||||
fun! s:X(a)
|
||||
if &t_Co == 88
|
||||
return a:a
|
||||
else
|
||||
if a:a == 8
|
||||
return 237
|
||||
elseif a:a < 16
|
||||
return a:a
|
||||
elseif a:a > 79
|
||||
return 232 + (3 * (a:a - 80))
|
||||
else
|
||||
let l:b = a:a - 16
|
||||
let l:x = l:b % 4
|
||||
let l:y = (l:b / 4) % 4
|
||||
let l:z = (l:b / 16)
|
||||
return 16 + s:M(l:x) + (6 * s:M(l:y)) + (36 * s:M(l:z))
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
function! E2T(a)
|
||||
return s:X(a:a)
|
||||
endfunction
|
||||
|
||||
function! s:choose(mediocre,good)
|
||||
if &t_Co != 88 && &t_Co != 256
|
||||
return a:mediocre
|
||||
else
|
||||
return s:X(a:good)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:hifg(group,guifg,first,second,...)
|
||||
if a:0 && &t_Co == 256
|
||||
let ctermfg = a:1
|
||||
else
|
||||
let ctermfg = s:choose(a:first,a:second)
|
||||
endif
|
||||
exe "highlight ".a:group." guifg=".a:guifg." ctermfg=".ctermfg
|
||||
endfunction
|
||||
|
||||
function! s:hibg(group,guibg,first,second)
|
||||
let ctermbg = s:choose(a:first,a:second)
|
||||
exe "highlight ".a:group." guibg=".a:guibg." ctermbg=".ctermbg
|
||||
endfunction
|
||||
|
||||
hi link railsMethod PreProc
|
||||
hi link rubyDefine Keyword
|
||||
hi link rubySymbol Constant
|
||||
hi link rubyAccess rubyMethod
|
||||
hi link rubyAttribute rubyMethod
|
||||
hi link rubyEval rubyMethod
|
||||
hi link rubyException rubyMethod
|
||||
hi link rubyInclude rubyMethod
|
||||
hi link rubyStringDelimiter rubyString
|
||||
hi link rubyRegexp Regexp
|
||||
hi link rubyRegexpDelimiter rubyRegexp
|
||||
"hi link rubyConstant Variable
|
||||
"hi link rubyGlobalVariable Variable
|
||||
"hi link rubyClassVariable Variable
|
||||
"hi link rubyInstanceVariable Variable
|
||||
hi link javascriptRegexpString Regexp
|
||||
hi link javascriptNumber Number
|
||||
hi link javascriptNull Constant
|
||||
highlight link diffAdded String
|
||||
highlight link diffRemoved Statement
|
||||
highlight link diffLine PreProc
|
||||
highlight link diffSubname Comment
|
||||
|
||||
call s:hifg("Normal","#EEEEEE","White",87)
|
||||
if &background == "light" || has("gui_running")
|
||||
hi Normal guibg=Black ctermbg=Black
|
||||
else
|
||||
hi Normal guibg=Black ctermbg=NONE
|
||||
endif
|
||||
highlight StatusLine guifg=Black guibg=#aabbee gui=bold ctermfg=Black ctermbg=White cterm=bold
|
||||
highlight StatusLineNC guifg=#444444 guibg=#aaaaaa gui=none ctermfg=Black ctermbg=Grey cterm=none
|
||||
"if &t_Co == 256
|
||||
"highlight StatusLine ctermbg=117
|
||||
"else
|
||||
"highlight StatusLine ctermbg=43
|
||||
"endif
|
||||
|
||||
highlight Ignore ctermfg=Black
|
||||
highlight WildMenu guifg=Black guibg=#ffff00 gui=bold ctermfg=Black ctermbg=Yellow cterm=bold
|
||||
highlight Cursor guifg=Black guibg=White ctermfg=Black ctermbg=White
|
||||
highlight CursorLine guibg=#333333 guifg=NONE
|
||||
highlight CursorColumn guibg=#333333 guifg=NONE
|
||||
highlight NonText guifg=#404040 ctermfg=8
|
||||
highlight SpecialKey guifg=#404040 ctermfg=8
|
||||
highlight Directory none
|
||||
high link Directory Identifier
|
||||
highlight ErrorMsg guibg=Red ctermbg=DarkRed guifg=NONE ctermfg=NONE
|
||||
highlight Search guifg=NONE ctermfg=NONE gui=none cterm=none
|
||||
call s:hibg("Search" ,"#555555","DarkBlue",81)
|
||||
highlight IncSearch guifg=White guibg=Black ctermfg=White ctermbg=Black
|
||||
highlight MoreMsg guifg=#00AA00 ctermfg=Green
|
||||
highlight LineNr guifg=#DDEEFF ctermfg=White
|
||||
call s:hibg("LineNr" ,"#222222","DarkBlue",80)
|
||||
highlight Question none
|
||||
high link Question MoreMsg
|
||||
highlight Title guifg=Magenta ctermfg=Magenta
|
||||
highlight VisualNOS gui=none cterm=none
|
||||
call s:hibg("Visual" ,"#555577","LightBlue",83)
|
||||
call s:hibg("VisualNOS" ,"#444444","DarkBlue",81)
|
||||
call s:hibg("MatchParen","#1100AA","DarkBlue",18)
|
||||
highlight WarningMsg guifg=Red ctermfg=Red
|
||||
highlight Error ctermbg=DarkRed
|
||||
highlight SpellBad ctermbg=DarkRed
|
||||
" FIXME: Comments
|
||||
highlight SpellRare ctermbg=DarkMagenta
|
||||
highlight SpellCap ctermbg=DarkBlue
|
||||
highlight SpellLocal ctermbg=DarkCyan
|
||||
|
||||
call s:hibg("Folded" ,"#110077","DarkBlue",17)
|
||||
call s:hifg("Folded" ,"#aaddee","LightCyan",63)
|
||||
highlight FoldColumn none
|
||||
high link FoldColumn Folded
|
||||
highlight DiffAdd ctermbg=4 guibg=DarkBlue
|
||||
highlight DiffChange ctermbg=5 guibg=DarkMagenta
|
||||
highlight DiffDelete ctermfg=12 ctermbg=6 gui=bold guifg=Blue guibg=DarkCyan
|
||||
highlight DiffText ctermbg=DarkRed
|
||||
highlight DiffText cterm=bold ctermbg=9 gui=bold guibg=Red
|
||||
|
||||
highlight Pmenu guifg=White ctermfg=White gui=bold cterm=bold
|
||||
highlight PmenuSel guifg=White ctermfg=White gui=bold cterm=bold
|
||||
call s:hibg("Pmenu" ,"#000099","Blue",18)
|
||||
call s:hibg("PmenuSel" ,"#5555ff","DarkCyan",39)
|
||||
highlight PmenuSbar guibg=Grey ctermbg=Grey
|
||||
highlight PmenuThumb guibg=White ctermbg=White
|
||||
highlight TabLine gui=underline cterm=underline
|
||||
call s:hifg("TabLine" ,"#bbbbbb","LightGrey",85)
|
||||
call s:hibg("TabLine" ,"#333333","DarkGrey",80)
|
||||
highlight TabLineSel guifg=White guibg=Black ctermfg=White ctermbg=Black
|
||||
highlight TabLineFill gui=underline cterm=underline
|
||||
call s:hifg("TabLineFill","#bbbbbb","LightGrey",85)
|
||||
call s:hibg("TabLineFill","#808080","Grey",83)
|
||||
|
||||
hi Type gui=none
|
||||
hi Statement gui=none
|
||||
if !has("gui_mac")
|
||||
" Mac GUI degrades italics to ugly underlining.
|
||||
hi Comment gui=italic
|
||||
hi railsUserClass gui=italic
|
||||
hi railsUserMethod gui=italic
|
||||
endif
|
||||
hi Identifier cterm=none
|
||||
" Commented numbers at the end are *old* 256 color values
|
||||
"highlight PreProc guifg=#EDF8F9
|
||||
call s:hifg("Comment" ,"#9933CC","DarkMagenta",34) " 92
|
||||
" 26 instead?
|
||||
call s:hifg("Constant" ,"#339999","DarkCyan",21) " 30
|
||||
call s:hifg("rubyNumber" ,"#CCFF33","Yellow",60) " 190
|
||||
call s:hifg("String" ,"#66FF00","LightGreen",44,82) " 82
|
||||
call s:hifg("Identifier" ,"#FFCC00","Yellow",72) " 220
|
||||
call s:hifg("Statement" ,"#FF6600","Brown",68) " 202
|
||||
call s:hifg("PreProc" ,"#AAFFFF","LightCyan",47) " 213
|
||||
call s:hifg("railsUserMethod","#AACCFF","LightCyan",27)
|
||||
call s:hifg("Type" ,"#AAAA77","Grey",57) " 101
|
||||
call s:hifg("railsUserClass" ,"#AAAAAA","Grey",7) " 101
|
||||
call s:hifg("Special" ,"#33AA00","DarkGreen",24) " 7
|
||||
call s:hifg("Regexp" ,"#44B4CC","DarkCyan",21) " 74
|
||||
call s:hifg("rubyMethod" ,"#DDE93D","Yellow",77) " 191
|
||||
"highlight railsMethod guifg=#EE1122 ctermfg=1
|
File diff suppressed because it is too large
Load Diff
@ -1,177 +0,0 @@
|
||||
|
||||
*alternate.txt* Alternate Plugin Sat May 13 15:35:38 CDT 2006
|
||||
|
||||
Author: Michael Sharpe <feline@irendi.com>
|
||||
Copyright: (c) 2000-2006 Michael Sharpe
|
||||
We grant permission to use, copy modify, distribute, and sell this
|
||||
software for any purpose without fee, provided that the above
|
||||
copyright notice and this text are not removed. We make no guarantee
|
||||
about the suitability of this software for any purpose and we are
|
||||
not liable for any damages resulting from its use. Further, we are
|
||||
under no obligation to maintain or extend this software. It is
|
||||
provided on an "as is" basis without any expressed or implied
|
||||
warranty.
|
||||
|
||||
==============================================================================
|
||||
1. Contents *AS* *AV* *AT* *AN* *IH* *IHS* *IHV* *IHT* *IHN* *alternate*
|
||||
|
||||
1. Contents...........................: |alternate|
|
||||
2. Purpose............................: |alternate-purpose|
|
||||
3. Commands...........................: |alternate-commands|
|
||||
4. Configuration......................: |alternate-config|
|
||||
5. Installation.......................: |alternate-installation|
|
||||
6. Bugs/Enhancements..................: |alternate-support|
|
||||
7. Acknowledgments....................: |alternate-acknowledgments|
|
||||
|
||||
==============================================================================
|
||||
2. Purpose *alternate-purpose*
|
||||
|
||||
The purpose of a.vim is to allow quick and easy switching between source files
|
||||
and corresponding header files. Many languages (C, C++, ada, ocaml, lex/yacc)
|
||||
have the concept of source/header files or the like. It is quite common during
|
||||
development or review to need to edit both files together. This plugin attempts
|
||||
to simplify that process. There are commands which while editing a source
|
||||
file allow for the quick switching to the corresponding header and vice versa.
|
||||
The only difference between the commands is how the switch occurs. More recent
|
||||
functionality allow the switching to a file under the cursor too. In the
|
||||
following sections the commands, configuration and installation procedures are
|
||||
described.
|
||||
|
||||
==============================================================================
|
||||
3. Commands *alternate-commands*
|
||||
|
||||
There are 4 commands provided by this plugin. They are
|
||||
|
||||
:A switches to the header file corresponding to the source file in the current
|
||||
buffer (or vice versa).
|
||||
|
||||
:AS similar to :A except the current buffer is split horizontally such that the
|
||||
source file is on one split and the header is in the other.
|
||||
|
||||
:AV similar to :AS except that the split is vertical
|
||||
|
||||
:AT similar to :AS and :AV except a new tab is opened instead of a split
|
||||
|
||||
:IH switches to the file under cursor (or the file specified with the
|
||||
command). This command uses the builtin a.vim search path support and the
|
||||
&path variable in conjunction.
|
||||
|
||||
:IHS similar to :IH execpt the current buffer is split horizontally first
|
||||
|
||||
:IHS similar to :IH execpt the current buffer is split vertically first
|
||||
|
||||
:IHS similar to :IH execpt a new tab is created for the file being switched to
|
||||
|
||||
:IHN switches to the next matching file for the original selection
|
||||
|
||||
In all cases if the corresponding alternate file is already loaded that buffer
|
||||
is preferred. That is this plugin will never load the same file twice.
|
||||
|
||||
Some maps are also provided for the IH command (mainly for example purposes)
|
||||
<Leader>ih - switches to the file under the cursor using the :IHS command
|
||||
<Leader>is - switches to the source file of the header file under the cursor
|
||||
using the :IHS command and the :A command
|
||||
<leader>ihn - switches to the next match in the sequence.
|
||||
|
||||
==============================================================================
|
||||
4. Configuration *alternate-config*
|
||||
|
||||
It is possible to configure three separate pieces of behaviour of this plugin.
|
||||
|
||||
a) Extensions: Each language has different extensions for identifying the
|
||||
source and header files. Many languages support multiple different but related
|
||||
extensions. As such this plugin allow for the complete specification of how
|
||||
source and header files correspond to each other via extension maps. There are
|
||||
a number of maps built in. For example, the following variable setting
|
||||
|
||||
g:alternateExtensions_CPP = "inc,h,H,HPP,hpp"
|
||||
|
||||
indicates that any file with a .CPP exetension can have a corresponding file
|
||||
with any of the .inc, .h, .H, .HPP, .hpp extension. The inverse is not
|
||||
specified by this map though. Typically each extension will have a mapping. So
|
||||
there would exist maps for .h, .inc, .H, .HPP, .hpp too. Extension maps should
|
||||
be specified before loading this plugin. Some of the builtin extension maps are
|
||||
as follows,
|
||||
|
||||
C and C++
|
||||
g:alternateExtensions_h = "c,cpp,cxx,cc,CC"
|
||||
g:alternateExtensions_H' = "C,CPP,CXX,CC"
|
||||
g:alternateExtensions_cpp' = "h,hpp"
|
||||
g:alternateExtensions_CPP' = "H,HPP"
|
||||
g:alternateExtensions_c' = "h"
|
||||
g:alternateExtensions_C' = "H"
|
||||
g:alternateExtensions_cxx' = "h"
|
||||
|
||||
Ada
|
||||
g:alternateExtensions_adb' = "ads"
|
||||
g:alternateExtensions_ads' = "adb"
|
||||
|
||||
Lex/Yacc
|
||||
g:alternateExtensions_l' = "y,yacc,ypp"
|
||||
g:alternateExtensions_lex' = "yacc,y,ypp"
|
||||
g:alternateExtensions_lpp' = "ypp,y,yacc"
|
||||
g:alternateExtensions_y' = "l,lex,lpp"
|
||||
g:alternateExtensions_yacc' = "lex,l,lpp"
|
||||
g:alternateExtensions_ypp' = "lpp,l,lex"
|
||||
|
||||
b) Search Paths: In many projects the location of the source files and the
|
||||
corresponding header files is not always the same directory. This plugin allows
|
||||
the search path it uses to locate source and header files to be configured.
|
||||
The search path is specified by setting the g:alternateSearchPath variable. The
|
||||
default setting is as follows,
|
||||
|
||||
g:alternateSearchPath = 'sfr:../source,sfr:../src,sfr:../include,sfr:../inc'
|
||||
|
||||
This indicates that the corresponding file will be searched for in ../source,
|
||||
../src. ../include and ../inc all relative to the current file being switched
|
||||
from. The value of the g:alternateSearchPath variable is simply a comma
|
||||
separated list of prefixes and directories. The "sfr:" prefix indicates that
|
||||
the path is relative to the file. Other prefixes are "wdr:" which indicates
|
||||
that the directory is relative to the current working directory and "abs:"
|
||||
which indicates the path is absolute. If no prefix is specified "sfr:" is
|
||||
assumed.
|
||||
|
||||
c) Regex Paths: Another type of prefix which can appear in the
|
||||
g:alternateSearchPath variable is that of "reg:". It is used to apply a regex
|
||||
to the path of the file in the buffer being switched from to locate the
|
||||
alternate file. E.g. 'reg:/inc/src/g/' will replace every instance of 'inc'
|
||||
with 'src' in the source file path. It is possible to use match variables so
|
||||
you could do something like: 'reg:|src/\([^/]*\)|inc/\1||' (see |substitute|,
|
||||
|help pattern| and |sub-replace-special| for more details. The exact syntax of
|
||||
a "reg:" specification is
|
||||
reg:<sep><pattern><sep><subst><sep><flag><sep>
|
||||
|
||||
<sep> seperator character, we often use one of [/|%#]
|
||||
<pattern> is what you are looking for
|
||||
<subst> is the output pattern
|
||||
<flag> can be g for global replace or empty
|
||||
|
||||
d) No Alternate Behaviour: When attempting to alternate/switch from a
|
||||
source/header to its corresponding file it is possible that the corresponding
|
||||
file does not exist. In this case this plugin will create the missing alternate
|
||||
file in the same directory as the current file. Some users find this behaviour
|
||||
irritating. This behaviour can be disabled by setting
|
||||
g:alternateNoDefaultAlternate to 1. When this variable is not 0 a message will
|
||||
be displayed indicating that no alternate file exists.
|
||||
|
||||
==============================================================================
|
||||
5. Installation *alternate-installation*
|
||||
|
||||
To install this plugin simply drop the a.vim file in to $VIMRUNTIME/plugin
|
||||
(global or local) or simply source the file from the vimrc file. Ensure that
|
||||
any configuration occurs before the plugin is loaded/sourced.
|
||||
|
||||
==============================================================================
|
||||
6. Bugs/Enhancements *alternate-support*
|
||||
|
||||
Whilst no formal support is provided for this plugin the author is always happy
|
||||
to receive bug reports and enhancement requests. Please email all such
|
||||
reports/requests to feline@irendi.com.
|
||||
|
||||
==============================================================================
|
||||
7. Acknowledgments *alternate-acknowledgments*
|
||||
|
||||
The author would like to thank everyone who has submitted bug reports and
|
||||
feature enhancement requests in the past. In particular Bindu Wavell provided
|
||||
much of the original code implementing the search path and regex functionality.
|
||||
vim:tw=78:ts=8:ft=help
|
File diff suppressed because it is too large
Load Diff
@ -1,36 +0,0 @@
|
||||
:TComment tcomment.txt /*:TComment*
|
||||
:TCommentAs tcomment.txt /*:TCommentAs*
|
||||
:TCommentBlock tcomment.txt /*:TCommentBlock*
|
||||
:TCommentInline tcomment.txt /*:TCommentInline*
|
||||
:TCommentMaybeInline tcomment.txt /*:TCommentMaybeInline*
|
||||
:TCommentRight tcomment.txt /*:TCommentRight*
|
||||
g:tcomment#ignore_char_type tcomment.txt /*g:tcomment#ignore_char_type*
|
||||
g:tcomment#syntax_substitute tcomment.txt /*g:tcomment#syntax_substitute*
|
||||
g:tcommentBlankLines tcomment.txt /*g:tcommentBlankLines*
|
||||
g:tcommentBlockC tcomment.txt /*g:tcommentBlockC*
|
||||
g:tcommentBlockC2 tcomment.txt /*g:tcommentBlockC2*
|
||||
g:tcommentBlockXML tcomment.txt /*g:tcommentBlockXML*
|
||||
g:tcommentGuessFileType tcomment.txt /*g:tcommentGuessFileType*
|
||||
g:tcommentGuessFileType_django tcomment.txt /*g:tcommentGuessFileType_django*
|
||||
g:tcommentGuessFileType_dsl tcomment.txt /*g:tcommentGuessFileType_dsl*
|
||||
g:tcommentGuessFileType_html tcomment.txt /*g:tcommentGuessFileType_html*
|
||||
g:tcommentGuessFileType_php tcomment.txt /*g:tcommentGuessFileType_php*
|
||||
g:tcommentGuessFileType_tskeleton tcomment.txt /*g:tcommentGuessFileType_tskeleton*
|
||||
g:tcommentGuessFileType_vim tcomment.txt /*g:tcommentGuessFileType_vim*
|
||||
g:tcommentIgnoreTypes_php tcomment.txt /*g:tcommentIgnoreTypes_php*
|
||||
g:tcommentInlineC tcomment.txt /*g:tcommentInlineC*
|
||||
g:tcommentInlineXML tcomment.txt /*g:tcommentInlineXML*
|
||||
g:tcommentMapLeaderOp1 tcomment.txt /*g:tcommentMapLeaderOp1*
|
||||
g:tcommentMapLeaderOp2 tcomment.txt /*g:tcommentMapLeaderOp2*
|
||||
g:tcommentOpModeExtra tcomment.txt /*g:tcommentOpModeExtra*
|
||||
g:tcommentOptions tcomment.txt /*g:tcommentOptions*
|
||||
g:tcommentSyntaxMap tcomment.txt /*g:tcommentSyntaxMap*
|
||||
tcomment#Comment() tcomment.txt /*tcomment#Comment()*
|
||||
tcomment#CommentAs() tcomment.txt /*tcomment#CommentAs()*
|
||||
tcomment#DefineType() tcomment.txt /*tcomment#DefineType()*
|
||||
tcomment#Operator() tcomment.txt /*tcomment#Operator()*
|
||||
tcomment#OperatorAnyway() tcomment.txt /*tcomment#OperatorAnyway()*
|
||||
tcomment#OperatorLine() tcomment.txt /*tcomment#OperatorLine()*
|
||||
tcomment#OperatorLineAnyway() tcomment.txt /*tcomment#OperatorLineAnyway()*
|
||||
tcomment-maps tcomment.txt /*tcomment-maps*
|
||||
tcomment.txt tcomment.txt /*tcomment.txt*
|
@ -1,359 +0,0 @@
|
||||
*tcomment.txt* An easily extensible & universal comment plugin
|
||||
Author: Thomas Link, micathom AT gmail com?subject=vim
|
||||
|
||||
tcomment provides easy to use, file-type sensible comments for Vim. It
|
||||
can handle embedded syntax.
|
||||
|
||||
TComment works like a toggle, i.e., it will comment out text that
|
||||
contains uncommented lines, and it will remove comment markup for
|
||||
already commented text (i.e. text that contains no uncommented lines).
|
||||
|
||||
If the file-type is properly defined, TComment will figure out which
|
||||
comment string to use. Otherwise you use |tcomment#DefineType()| to
|
||||
override the default choice.
|
||||
|
||||
TComment can properly handle an embedded syntax, e.g., ruby/python/perl
|
||||
regions in vim scripts, HTML or JavaScript in php code etc.
|
||||
|
||||
Demo:
|
||||
http://vimsomnia.blogspot.com/2010/11/tcomment-vim-plugin.html
|
||||
|
||||
|
||||
*tcomment-maps*
|
||||
Key bindings~
|
||||
|
||||
Most of the time the default toggle keys will do what you want (or to be
|
||||
more precise: what I think you want it to do ;-).
|
||||
|
||||
*g:tcommentMapLeaderOp1*
|
||||
*g:tcommentMapLeaderOp2*
|
||||
As operator (the prefix can be customized via g:tcommentMapLeaderOp1
|
||||
and g:tcommentMapLeaderOp2):
|
||||
|
||||
gc{motion} :: Toggle comments (for small comments within one line
|
||||
the &filetype_inline style will be used, if
|
||||
defined)
|
||||
gcc :: Toggle comment for the current line
|
||||
gC{motion} :: Comment region
|
||||
gCc :: Comment the current line
|
||||
|
||||
By default the cursor stays put. If you want the cursor to the end of
|
||||
the commented text, set |g:tcommentOpModeExtra| to '>' (but this may not
|
||||
work properly with exclusive motions).
|
||||
|
||||
Primary key maps:
|
||||
|
||||
<c-_><c-_> :: :TComment
|
||||
<c-_><space> :: :TComment <QUERY COMMENT-BEGIN ?COMMENT-END>
|
||||
<c-_>b :: :TCommentBlock
|
||||
<c-_>a :: :TCommentAs <QUERY COMMENT TYPE>
|
||||
<c-_>n :: :TCommentAs &filetype <QUERY COUNT>
|
||||
<c-_>s :: :TCommentAs &filetype_<QUERY COMMENT SUBTYPE>
|
||||
<c-_>i :: :TCommentInline
|
||||
<c-_>r :: :TCommentRight
|
||||
<c-_>p :: Comment the current inner paragraph
|
||||
|
||||
A secondary set of key maps is defined for normal mode.
|
||||
|
||||
<Leader>__ :: :TComment
|
||||
<Leader>_p :: Comment the current inner paragraph
|
||||
<Leader>_<space> :: :TComment <QUERY COMMENT-BEGIN ?COMMENT-END>
|
||||
<Leader>_i :: :TCommentInline
|
||||
<Leader>_r :: :TCommentRight
|
||||
<Leader>_b :: :TCommentBlock
|
||||
<Leader>_a :: :TCommentAs <QUERY COMMENT TYPE>
|
||||
<Leader>_n :: :TCommentAs &filetype <QUERY COUNT>
|
||||
<Leader>_s :: :TCommentAs &filetype_<QUERY COMMENT SUBTYPE>
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
Install~
|
||||
|
||||
Edit the vba file and type: >
|
||||
|
||||
:so %
|
||||
|
||||
See :help vimball for details. If you have difficulties or use vim 7.0,
|
||||
please make sure, you have the current version of vimball (vimscript
|
||||
#1502) installed or update your runtime.
|
||||
|
||||
|
||||
========================================================================
|
||||
Contents~
|
||||
|
||||
:TComment ........................... |:TComment|
|
||||
:TCommentAs ......................... |:TCommentAs|
|
||||
:TCommentRight ...................... |:TCommentRight|
|
||||
:TCommentBlock ...................... |:TCommentBlock|
|
||||
:TCommentInline ..................... |:TCommentInline|
|
||||
:TCommentMaybeInline ................ |:TCommentMaybeInline|
|
||||
g:tcommentBlankLines ................ |g:tcommentBlankLines|
|
||||
g:tcommentOpModeExtra ............... |g:tcommentOpModeExtra|
|
||||
g:tcommentOptions ................... |g:tcommentOptions|
|
||||
g:tcomment#ignore_char_type ......... |g:tcomment#ignore_char_type|
|
||||
g:tcommentGuessFileType ............. |g:tcommentGuessFileType|
|
||||
g:tcommentGuessFileType_dsl ......... |g:tcommentGuessFileType_dsl|
|
||||
g:tcommentGuessFileType_php ......... |g:tcommentGuessFileType_php|
|
||||
g:tcommentGuessFileType_html ........ |g:tcommentGuessFileType_html|
|
||||
g:tcommentGuessFileType_tskeleton ... |g:tcommentGuessFileType_tskeleton|
|
||||
g:tcommentGuessFileType_vim ......... |g:tcommentGuessFileType_vim|
|
||||
g:tcommentGuessFileType_django ...... |g:tcommentGuessFileType_django|
|
||||
g:tcommentIgnoreTypes_php ........... |g:tcommentIgnoreTypes_php|
|
||||
g:tcomment#syntax_substitute ........ |g:tcomment#syntax_substitute|
|
||||
g:tcommentSyntaxMap ................. |g:tcommentSyntaxMap|
|
||||
g:tcommentBlockC .................... |g:tcommentBlockC|
|
||||
g:tcommentBlockC2 ................... |g:tcommentBlockC2|
|
||||
g:tcommentInlineC ................... |g:tcommentInlineC|
|
||||
g:tcommentBlockXML .................. |g:tcommentBlockXML|
|
||||
g:tcommentInlineXML ................. |g:tcommentInlineXML|
|
||||
tcomment#DefineType ................. |tcomment#DefineType()|
|
||||
tcomment#Comment .................... |tcomment#Comment()|
|
||||
tcomment#Operator ................... |tcomment#Operator()|
|
||||
tcomment#OperatorLine ............... |tcomment#OperatorLine()|
|
||||
tcomment#OperatorAnyway ............. |tcomment#OperatorAnyway()|
|
||||
tcomment#OperatorLineAnyway ......... |tcomment#OperatorLineAnyway()|
|
||||
tcomment#CommentAs .................. |tcomment#CommentAs()|
|
||||
|
||||
|
||||
========================================================================
|
||||
plugin/tcomment.vim~
|
||||
|
||||
*:TComment*
|
||||
:[range]TComment[!] ?ARGS...
|
||||
If there is a visual selection that begins and ends in the same line,
|
||||
then |:TCommentInline| is used instead.
|
||||
The optional range defaults to the current line. With a bang '!',
|
||||
always comment the line.
|
||||
|
||||
ARGS... are either (see also |tcomment#Comment()|):
|
||||
1. a list of key=value pairs
|
||||
2. 1-2 values for: ?commentBegin, ?commentEnd
|
||||
|
||||
*:TCommentAs*
|
||||
:[range]TCommentAs[!] commenttype ?ARGS...
|
||||
TCommentAs requires g:tcomment_{filetype} to be defined.
|
||||
With a bang '!', always comment the line.
|
||||
|
||||
ARGS... are either (see also |tcomment#Comment()|):
|
||||
1. a list of key=value pairs
|
||||
2. 1-2 values for: ?commentBegin, ?commentEnd
|
||||
|
||||
*:TCommentRight*
|
||||
:[range]TCommentRight[!] ?ARGS...
|
||||
Comment the text to the right of the cursor. If a visual selection was
|
||||
made (be it block-wise or not), all lines are commented out at from
|
||||
the current cursor position downwards.
|
||||
With a bang '!', always comment the line.
|
||||
|
||||
ARGS... are either (see also |tcomment#Comment()|):
|
||||
1. a list of key=value pairs
|
||||
2. 1-2 values for: ?commentBegin, ?commentEnd
|
||||
|
||||
*:TCommentBlock*
|
||||
:[range]TCommentBlock[!] ?ARGS...
|
||||
Comment as "block", e.g. use the {&ft}_block comment style. The
|
||||
commented text isn't indented or reformated.
|
||||
With a bang '!', always comment the line.
|
||||
|
||||
ARGS... are either (see also |tcomment#Comment()|):
|
||||
1. a list of key=value pairs
|
||||
2. 1-2 values for: ?commentBegin, ?commentEnd
|
||||
|
||||
*:TCommentInline*
|
||||
:[range]TCommentInline[!] ?ARGS...
|
||||
Use the {&ft}_inline comment style.
|
||||
With a bang '!', always comment the line.
|
||||
|
||||
ARGS... are either (see also |tcomment#Comment()|):
|
||||
1. a list of key=value pairs
|
||||
2. 1-2 values for: ?commentBegin, ?commentEnd
|
||||
|
||||
*:TCommentMaybeInline*
|
||||
:[range]TCommentMaybeInline[!] ?ARGS...
|
||||
With a bang '!', always comment the line.
|
||||
|
||||
ARGS... are either (see also |tcomment#Comment()|):
|
||||
1. a list of key=value pairs
|
||||
2. 1-2 values for: ?commentBegin, ?commentEnd
|
||||
|
||||
|
||||
========================================================================
|
||||
autoload/tcomment.vim~
|
||||
|
||||
*g:tcommentBlankLines*
|
||||
g:tcommentBlankLines (default: 1)
|
||||
If true, comment blank lines too
|
||||
|
||||
*g:tcommentOpModeExtra*
|
||||
g:tcommentOpModeExtra (default: '')
|
||||
Modifies how the operator works.
|
||||
> ... Move the cursor to the end of the comment
|
||||
|
||||
*g:tcommentOptions*
|
||||
g:tcommentOptions (default: {})
|
||||
Other key-value options used by |tcomment#Comment()|.
|
||||
|
||||
Example: If you want to put the opening comment marker always in
|
||||
the first column regardless of the block's indentation, put this
|
||||
into your |vimrc| file: >
|
||||
let g:tcommentOptions = {'col': 1}
|
||||
<
|
||||
|
||||
*g:tcomment#ignore_char_type*
|
||||
g:tcomment#ignore_char_type (default: 1)
|
||||
|text-objects| for use with |tcomment#Operator| can have different
|
||||
types: line, block, char etc. Text objects like aB, it, at etc.
|
||||
have type char but this may not work reliably. By default,
|
||||
tcomment handles those text objects most often as if they were of
|
||||
type line. Set this variable to 0 in order to change this
|
||||
behaviour. Be prepared that the result may not always match your
|
||||
intentions.
|
||||
|
||||
*g:tcommentGuessFileType*
|
||||
g:tcommentGuessFileType (default: 0)
|
||||
Guess the file type based on syntax names always or for some fileformat only
|
||||
If non-zero, try to guess filetypes.
|
||||
tcomment also checks g:tcommentGuessFileType_{&filetype} for
|
||||
filetype specific values.
|
||||
|
||||
Values:
|
||||
0 ... don't guess
|
||||
1 ... guess
|
||||
FILETYPE ... assume this filetype
|
||||
|
||||
*g:tcommentGuessFileType_dsl*
|
||||
g:tcommentGuessFileType_dsl (default: 'xml')
|
||||
For dsl documents, assumet filetype = xml.
|
||||
|
||||
*g:tcommentGuessFileType_php*
|
||||
g:tcommentGuessFileType_php (default: 'html')
|
||||
In php documents, the php part is usually marked as phpRegion. We
|
||||
thus assume that the buffers default comment style isn't php but
|
||||
html.
|
||||
|
||||
*g:tcommentGuessFileType_html*
|
||||
g:tcommentGuessFileType_html (default: 1)
|
||||
|
||||
*g:tcommentGuessFileType_tskeleton*
|
||||
g:tcommentGuessFileType_tskeleton (default: 1)
|
||||
|
||||
*g:tcommentGuessFileType_vim*
|
||||
g:tcommentGuessFileType_vim (default: 1)
|
||||
|
||||
*g:tcommentGuessFileType_django*
|
||||
g:tcommentGuessFileType_django (default: 1)
|
||||
|
||||
*g:tcommentIgnoreTypes_php*
|
||||
g:tcommentIgnoreTypes_php (default: 'sql')
|
||||
In php files, some syntax regions are wongly highlighted as sql
|
||||
markup. We thus ignore sql syntax when guessing the filetype in
|
||||
php files.
|
||||
|
||||
*g:tcomment#syntax_substitute*
|
||||
g:tcomment#syntax_substitute (default: {...})
|
||||
|
||||
*g:tcommentSyntaxMap*
|
||||
g:tcommentSyntaxMap (default: {...})
|
||||
tcomment guesses filetypes based on the name of the current syntax
|
||||
region. This works well if the syntax names match
|
||||
/filetypeSomeName/. Other syntax names have to be explicitly
|
||||
mapped onto the corresponding filetype.
|
||||
|
||||
*g:tcommentBlockC*
|
||||
g:tcommentBlockC (default: {...})
|
||||
Generic c-like block comments.
|
||||
|
||||
*g:tcommentBlockC2*
|
||||
g:tcommentBlockC2 (default: {...})
|
||||
Generic c-like block comments (alternative markup).
|
||||
|
||||
*g:tcommentInlineC*
|
||||
g:tcommentInlineC (default: "/* %s */")
|
||||
Generic c-like comments.
|
||||
|
||||
*g:tcommentBlockXML*
|
||||
g:tcommentBlockXML (default: "<!--%s-->\n ")
|
||||
Generic xml-like block comments.
|
||||
|
||||
*g:tcommentInlineXML*
|
||||
g:tcommentInlineXML (default: "<!-- %s -->")
|
||||
Generic xml-like comments.
|
||||
|
||||
*tcomment#DefineType()*
|
||||
tcomment#DefineType(name, commentdef)
|
||||
If you don't explicitly define a comment style, |:TComment| will use
|
||||
'commentstring' instead. We override the default values here in order
|
||||
to have a blank after the comment marker. Block comments work only if
|
||||
we explicitly define the markup.
|
||||
|
||||
The comment definition can be either a string or a dictionary.
|
||||
|
||||
If it is a string:
|
||||
The format for block comments is similar to 'commentstrings' with the
|
||||
exception that the format strings for blocks can contain a second line
|
||||
that defines how "middle lines" (see :h format-comments) should be
|
||||
displayed.
|
||||
|
||||
If it is a dictionary:
|
||||
See the help on the args argument of |tcomment#Comment|.
|
||||
|
||||
*tcomment#Comment()*
|
||||
tcomment#Comment(beg, end, ...)
|
||||
tcomment#Comment(line1, line2, ?commentMode, ?commentAnyway, ?args...)
|
||||
args... are either:
|
||||
1. a list of key=value pairs where known keys are (see also
|
||||
|g:tcommentOptions|):
|
||||
as=STRING ... Use a specific comment definition
|
||||
col=N ... Start the comment at column N (in block
|
||||
mode; must be smaller than |indent()|)
|
||||
mode=STRING ... See the notes below on the "commentMode" argument
|
||||
begin=STRING ... Comment prefix
|
||||
end=STRING ... Comment postfix
|
||||
middle=STRING ... Middle line comments in block mode
|
||||
rxbeg=N ... Regexp to find the substring of "begin"
|
||||
that should be multipied by "count"
|
||||
rxend=N ... The above for "end"
|
||||
rxmid=N ... The above for "middle"
|
||||
commentstring_rx ... A regexp format string that matches
|
||||
commented lines (no new groups may be
|
||||
introduced, the |regexp| is |\V|; % have
|
||||
to be doubled); "commentstring", "begin"
|
||||
and optionally "end" must be defined or
|
||||
deducible.
|
||||
2. 1-2 values for: ?commentPrefix, ?commentPostfix
|
||||
3. a dictionary (internal use only)
|
||||
|
||||
commentMode:
|
||||
G ... guess the value of commentMode
|
||||
B ... block (use extra lines for the comment markers)
|
||||
i ... maybe inline, guess
|
||||
I ... inline
|
||||
R ... right (comment the line right of the cursor)
|
||||
v ... visual
|
||||
o ... operator
|
||||
By default, each line in range will be commented by adding the comment
|
||||
prefix and postfix.
|
||||
|
||||
*tcomment#Operator()*
|
||||
tcomment#Operator(type, ...)
|
||||
|
||||
*tcomment#OperatorLine()*
|
||||
tcomment#OperatorLine(type)
|
||||
|
||||
*tcomment#OperatorAnyway()*
|
||||
tcomment#OperatorAnyway(type)
|
||||
|
||||
*tcomment#OperatorLineAnyway()*
|
||||
tcomment#OperatorLineAnyway(type)
|
||||
|
||||
*tcomment#CommentAs()*
|
||||
tcomment#CommentAs(beg, end, commentAnyway, filetype, ?args...)
|
||||
Where args is either:
|
||||
1. A count NUMBER
|
||||
2. An args list (see the notes on the "args" argument of
|
||||
|tcomment#Comment()|)
|
||||
comment text as if it were of a specific filetype
|
||||
|
||||
|
||||
|
||||
vim:tw=78:fo=tcq2:isk=!-~,^*,^|,^":ts=8:ft=help:norl:
|
@ -1,41 +0,0 @@
|
||||
" ============================================================================
|
||||
" File: exec_menuitem.vim
|
||||
" Description: plugin for NERD Tree that provides an execute file menu item
|
||||
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
" Last Change: 22 July, 2009
|
||||
" License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
" ============================================================================
|
||||
if exists("g:loaded_nerdtree_exec_menuitem")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_nerdtree_exec_menuitem = 1
|
||||
|
||||
call NERDTreeAddMenuItem({
|
||||
\ 'text': '(!)Execute file',
|
||||
\ 'shortcut': '!',
|
||||
\ 'callback': 'NERDTreeExecFile',
|
||||
\ 'isActiveCallback': 'NERDTreeExecFileActive' })
|
||||
|
||||
function! NERDTreeExecFileActive()
|
||||
let node = g:NERDTreeFileNode.GetSelected()
|
||||
return !node.path.isDirectory && node.path.isExecutable
|
||||
endfunction
|
||||
|
||||
function! NERDTreeExecFile()
|
||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||
echo "==========================================================\n"
|
||||
echo "Complete the command to execute (add arguments etc):\n"
|
||||
let cmd = treenode.path.str({'escape': 1})
|
||||
let cmd = input(':!', cmd . ' ')
|
||||
|
||||
if cmd != ''
|
||||
exec ':!' . cmd
|
||||
else
|
||||
echo "Aborted"
|
||||
endif
|
||||
endfunction
|
@ -1,224 +0,0 @@
|
||||
" ============================================================================
|
||||
" File: fs_menu.vim
|
||||
" Description: plugin for the NERD Tree that provides a file system menu
|
||||
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
" Last Change: 17 July, 2009
|
||||
" License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
" ============================================================================
|
||||
if exists("g:loaded_nerdtree_fs_menu")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_nerdtree_fs_menu = 1
|
||||
|
||||
call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'})
|
||||
call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
|
||||
call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
|
||||
|
||||
if has("gui_mac") || has("gui_macvim")
|
||||
call NERDTreeAddMenuItem({'text': '(r)eveal in Finder the current node', 'shortcut': 'r', 'callback': 'NERDTreeRevealInFinder'})
|
||||
call NERDTreeAddMenuItem({'text': '(o)pen the current node with system editor', 'shortcut': 'o', 'callback': 'NERDTreeExecuteFile'})
|
||||
call NERDTreeAddMenuItem({'text': '(q)uicklook the current node', 'shortcut': 'q', 'callback': 'NERDTreeQuickLook'})
|
||||
endif
|
||||
|
||||
if g:NERDTreePath.CopyingSupported()
|
||||
call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
|
||||
endif
|
||||
|
||||
"FUNCTION: s:echo(msg){{{1
|
||||
function! s:echo(msg)
|
||||
redraw
|
||||
echomsg "NERDTree: " . a:msg
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:echoWarning(msg){{{1
|
||||
function! s:echoWarning(msg)
|
||||
echohl warningmsg
|
||||
call s:echo(a:msg)
|
||||
echohl normal
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1
|
||||
"prints out the given msg and, if the user responds by pushing 'y' then the
|
||||
"buffer with the given bufnum is deleted
|
||||
"
|
||||
"Args:
|
||||
"bufnum: the buffer that may be deleted
|
||||
"msg: a message that will be echoed to the user asking them if they wish to
|
||||
" del the buffer
|
||||
function! s:promptToDelBuffer(bufnum, msg)
|
||||
echo a:msg
|
||||
if nr2char(getchar()) ==# 'y'
|
||||
exec "silent bdelete! " . a:bufnum
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: NERDTreeAddNode(){{{1
|
||||
function! NERDTreeAddNode()
|
||||
let curDirNode = g:NERDTreeDirNode.GetSelected()
|
||||
|
||||
let newNodeName = input("Add a childnode\n".
|
||||
\ "==========================================================\n".
|
||||
\ "Enter the dir/file name to be created. Dirs end with a '/'\n" .
|
||||
\ "", curDirNode.path.str() . g:NERDTreePath.Slash(), "file")
|
||||
|
||||
if newNodeName ==# ''
|
||||
call s:echo("Node Creation Aborted.")
|
||||
return
|
||||
endif
|
||||
|
||||
try
|
||||
let newPath = g:NERDTreePath.Create(newNodeName)
|
||||
let parentNode = b:NERDTreeRoot.findNode(newPath.getParent())
|
||||
|
||||
let newTreeNode = g:NERDTreeFileNode.New(newPath)
|
||||
if parentNode.isOpen || !empty(parentNode.children)
|
||||
call parentNode.addChild(newTreeNode, 1)
|
||||
call NERDTreeRender()
|
||||
call newTreeNode.putCursorHere(1, 0)
|
||||
endif
|
||||
catch /^NERDTree/
|
||||
call s:echoWarning("Node Not Created.")
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
"FUNCTION: NERDTreeMoveNode(){{{1
|
||||
function! NERDTreeMoveNode()
|
||||
let curNode = g:NERDTreeFileNode.GetSelected()
|
||||
let newNodePath = input("Rename the current node\n" .
|
||||
\ "==========================================================\n" .
|
||||
\ "Enter the new path for the node: \n" .
|
||||
\ "", curNode.path.str(), "file")
|
||||
|
||||
if newNodePath ==# ''
|
||||
call s:echo("Node Renaming Aborted.")
|
||||
return
|
||||
endif
|
||||
|
||||
try
|
||||
let bufnum = bufnr(curNode.path.str())
|
||||
|
||||
call curNode.rename(newNodePath)
|
||||
call NERDTreeRender()
|
||||
|
||||
"if the node is open in a buffer, ask the user if they want to
|
||||
"close that buffer
|
||||
if bufnum != -1
|
||||
let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
|
||||
call s:promptToDelBuffer(bufnum, prompt)
|
||||
endif
|
||||
|
||||
call curNode.putCursorHere(1, 0)
|
||||
|
||||
redraw
|
||||
catch /^NERDTree/
|
||||
call s:echoWarning("Node Not Renamed.")
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" FUNCTION: NERDTreeDeleteNode() {{{1
|
||||
function! NERDTreeDeleteNode()
|
||||
let currentNode = g:NERDTreeFileNode.GetSelected()
|
||||
let confirmed = 0
|
||||
|
||||
if currentNode.path.isDirectory
|
||||
let choice =input("Delete the current node\n" .
|
||||
\ "==========================================================\n" .
|
||||
\ "STOP! To delete this entire directory, type 'yes'\n" .
|
||||
\ "" . currentNode.path.str() . ": ")
|
||||
let confirmed = choice ==# 'yes'
|
||||
else
|
||||
echo "Delete the current node\n" .
|
||||
\ "==========================================================\n".
|
||||
\ "Are you sure you wish to delete the node:\n" .
|
||||
\ "" . currentNode.path.str() . " (yN):"
|
||||
let choice = nr2char(getchar())
|
||||
let confirmed = choice ==# 'y'
|
||||
endif
|
||||
|
||||
|
||||
if confirmed
|
||||
try
|
||||
call currentNode.delete()
|
||||
call NERDTreeRender()
|
||||
|
||||
"if the node is open in a buffer, ask the user if they want to
|
||||
"close that buffer
|
||||
let bufnum = bufnr(currentNode.path.str())
|
||||
if buflisted(bufnum)
|
||||
let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)"
|
||||
call s:promptToDelBuffer(bufnum, prompt)
|
||||
endif
|
||||
|
||||
redraw
|
||||
catch /^NERDTree/
|
||||
call s:echoWarning("Could not remove node")
|
||||
endtry
|
||||
else
|
||||
call s:echo("delete aborted")
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
" FUNCTION: NERDTreeCopyNode() {{{1
|
||||
function! NERDTreeCopyNode()
|
||||
let currentNode = g:NERDTreeFileNode.GetSelected()
|
||||
let newNodePath = input("Copy the current node\n" .
|
||||
\ "==========================================================\n" .
|
||||
\ "Enter the new path to copy the node to: \n" .
|
||||
\ "", currentNode.path.str(), "file")
|
||||
|
||||
if newNodePath != ""
|
||||
"strip trailing slash
|
||||
let newNodePath = substitute(newNodePath, '\/$', '', '')
|
||||
|
||||
let confirmed = 1
|
||||
if currentNode.path.copyingWillOverwrite(newNodePath)
|
||||
call s:echo("Warning: copying may overwrite files! Continue? (yN)")
|
||||
let choice = nr2char(getchar())
|
||||
let confirmed = choice ==# 'y'
|
||||
endif
|
||||
|
||||
if confirmed
|
||||
try
|
||||
let newNode = currentNode.copy(newNodePath)
|
||||
if !empty(newNode)
|
||||
call NERDTreeRender()
|
||||
call newNode.putCursorHere(0, 0)
|
||||
endif
|
||||
catch /^NERDTree/
|
||||
call s:echoWarning("Could not copy node")
|
||||
endtry
|
||||
endif
|
||||
else
|
||||
call s:echo("Copy aborted.")
|
||||
endif
|
||||
redraw
|
||||
endfunction
|
||||
|
||||
function! NERDTreeQuickLook()
|
||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||
if treenode != {}
|
||||
call system("qlmanage -p 2>/dev/null '" . treenode.path.str() . "'")
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! NERDTreeRevealInFinder()
|
||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||
if treenode != {}
|
||||
let x = system("open -R '" . treenode.path.str() . "'")
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! NERDTreeExecuteFile()
|
||||
let treenode = g:NERDTreeFileNode.GetSelected()
|
||||
if treenode != {}
|
||||
let x = system("open '" . treenode.path.str() . "'")
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
File diff suppressed because it is too large
Load Diff
@ -1,840 +0,0 @@
|
||||
" Copyright (c) 1998-2006
|
||||
" Michael Sharpe <feline@irendi.com>
|
||||
"
|
||||
" We grant permission to use, copy modify, distribute, and sell this
|
||||
" software for any purpose without fee, provided that the above copyright
|
||||
" notice and this text are not removed. We make no guarantee about the
|
||||
" suitability of this software for any purpose and we are not liable
|
||||
" for any damages resulting from its use. Further, we are under no
|
||||
" obligation to maintain or extend this software. It is provided on an
|
||||
" "as is" basis without any expressed or implied warranty.
|
||||
|
||||
" Directory & regex enhancements added by Bindu Wavell who is well known on
|
||||
" vim.sf.net
|
||||
"
|
||||
" Patch for spaces in files/directories from Nathan Stien (also reported by
|
||||
" Soeren Sonnenburg)
|
||||
|
||||
" Do not load a.vim if is has already been loaded.
|
||||
if exists("loaded_alternateFile")
|
||||
finish
|
||||
endif
|
||||
if (v:progname == "ex")
|
||||
finish
|
||||
endif
|
||||
let loaded_alternateFile = 1
|
||||
|
||||
let alternateExtensionsDict = {}
|
||||
|
||||
" setup the default set of alternate extensions. The user can override in thier
|
||||
" .vimrc if the defaults are not suitable. To override in a .vimrc simply set a
|
||||
" g:alternateExtensions_<EXT> variable to a comma separated list of alternates,
|
||||
" where <EXT> is the extension to map.
|
||||
" E.g. let g:alternateExtensions_CPP = "inc,h,H,HPP,hpp"
|
||||
" let g:alternateExtensions_{'aspx.cs'} = "aspx"
|
||||
|
||||
|
||||
" This variable will be increased when an extension with greater number of dots
|
||||
" is added by the AddAlternateExtensionMapping call.
|
||||
let s:maxDotsInExtension = 1
|
||||
|
||||
" Function : AddAlternateExtensionMapping (PRIVATE)
|
||||
" Purpose : simple helper function to add the default alternate extension
|
||||
" mappings.
|
||||
" Args : extension -- the extension to map
|
||||
" alternates -- comma separated list of alternates extensions
|
||||
" Returns : nothing
|
||||
" Author : Michael Sharpe <feline@irendi.com>
|
||||
function! <SID>AddAlternateExtensionMapping(extension, alternates)
|
||||
" This code does not actually work for variables like foo{'a.b.c.d.e'}
|
||||
"let varName = "g:alternateExtensions_" . a:extension
|
||||
"if (!exists(varName))
|
||||
" let g:alternateExtensions_{a:extension} = a:alternates
|
||||
"endif
|
||||
|
||||
" This code handles extensions which contains a dot. exists() fails with
|
||||
" such names.
|
||||
"let v:errmsg = ""
|
||||
" FIXME this line causes ex to return 1 instead of 0 for some reason??
|
||||
"silent! echo g:alternateExtensions_{a:extension}
|
||||
"if (v:errmsg != "")
|
||||
"let g:alternateExtensions_{a:extension} = a:alternates
|
||||
"endif
|
||||
|
||||
let g:alternateExtensionsDict[a:extension] = a:alternates
|
||||
let dotsNumber = strlen(substitute(a:extension, "[^.]", "", "g"))
|
||||
if s:maxDotsInExtension < dotsNumber
|
||||
let s:maxDotsInExtension = dotsNumber
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
" Add all the default extensions
|
||||
" Mappings for C and C++
|
||||
call <SID>AddAlternateExtensionMapping('h',"c,cpp,cxx,cc,CC")
|
||||
call <SID>AddAlternateExtensionMapping('H',"C,CPP,CXX,CC")
|
||||
call <SID>AddAlternateExtensionMapping('hpp',"cpp,c")
|
||||
call <SID>AddAlternateExtensionMapping('HPP',"CPP,C")
|
||||
call <SID>AddAlternateExtensionMapping('c',"h")
|
||||
call <SID>AddAlternateExtensionMapping('C',"H")
|
||||
call <SID>AddAlternateExtensionMapping('cpp',"h,hpp")
|
||||
call <SID>AddAlternateExtensionMapping('CPP',"H,HPP")
|
||||
call <SID>AddAlternateExtensionMapping('cc',"h")
|
||||
call <SID>AddAlternateExtensionMapping('CC',"H,h")
|
||||
call <SID>AddAlternateExtensionMapping('cxx',"h")
|
||||
call <SID>AddAlternateExtensionMapping('CXX',"H")
|
||||
" Mappings for PSL7
|
||||
call <SID>AddAlternateExtensionMapping('psl',"ph")
|
||||
call <SID>AddAlternateExtensionMapping('ph',"psl")
|
||||
" Mappings for ADA
|
||||
call <SID>AddAlternateExtensionMapping('adb',"ads")
|
||||
call <SID>AddAlternateExtensionMapping('ads',"adb")
|
||||
" Mappings for lex and yacc files
|
||||
call <SID>AddAlternateExtensionMapping('l',"y,yacc,ypp")
|
||||
call <SID>AddAlternateExtensionMapping('lex',"yacc,y,ypp")
|
||||
call <SID>AddAlternateExtensionMapping('lpp',"ypp,y,yacc")
|
||||
call <SID>AddAlternateExtensionMapping('y',"l,lex,lpp")
|
||||
call <SID>AddAlternateExtensionMapping('yacc',"lex,l,lpp")
|
||||
call <SID>AddAlternateExtensionMapping('ypp',"lpp,l,lex")
|
||||
" Mappings for OCaml
|
||||
call <SID>AddAlternateExtensionMapping('ml',"mli")
|
||||
call <SID>AddAlternateExtensionMapping('mli',"ml")
|
||||
" ASP stuff
|
||||
call <SID>AddAlternateExtensionMapping('aspx.cs', 'aspx')
|
||||
call <SID>AddAlternateExtensionMapping('aspx.vb', 'aspx')
|
||||
call <SID>AddAlternateExtensionMapping('aspx', 'aspx.cs,aspx.vb')
|
||||
|
||||
" Setup default search path, unless the user has specified
|
||||
" a path in their [._]vimrc.
|
||||
if (!exists('g:alternateSearchPath'))
|
||||
let g:alternateSearchPath = 'sfr:../source,sfr:../src,sfr:../include,sfr:../inc'
|
||||
endif
|
||||
|
||||
" If this variable is true then a.vim will not alternate to a file/buffer which
|
||||
" does not exist. E.g while editing a.c and the :A will not swtich to a.h
|
||||
" unless it exists.
|
||||
if (!exists('g:alternateNoDefaultAlternate'))
|
||||
" by default a.vim will alternate to a file which does not exist
|
||||
let g:alternateNoDefaultAlternate = 0
|
||||
endif
|
||||
|
||||
" If this variable is true then a.vim will convert the alternate filename to a
|
||||
" filename relative to the current working directory.
|
||||
" Feature by Nathan Huizinga
|
||||
if (!exists('g:alternateRelativeFiles'))
|
||||
" by default a.vim will not convert the filename to one relative to the
|
||||
" current working directory
|
||||
let g:alternateRelativeFiles = 0
|
||||
endif
|
||||
|
||||
|
||||
" Function : GetNthItemFromList (PRIVATE)
|
||||
" Purpose : Support reading items from a comma seperated list
|
||||
" Used to iterate all the extensions in an extension spec
|
||||
" Used to iterate all path prefixes
|
||||
" Args : list -- the list (extension spec, file paths) to iterate
|
||||
" n -- the extension to get
|
||||
" Returns : the nth item (extension, path) from the list (extension
|
||||
" spec), or "" for failure
|
||||
" Author : Michael Sharpe <feline@irendi.com>
|
||||
" History : Renamed from GetNthExtensionFromSpec to GetNthItemFromList
|
||||
" to reflect a more generic use of this function. -- Bindu
|
||||
function! <SID>GetNthItemFromList(list, n)
|
||||
let itemStart = 0
|
||||
let itemEnd = -1
|
||||
let pos = 0
|
||||
let item = ""
|
||||
let i = 0
|
||||
while (i != a:n)
|
||||
let itemStart = itemEnd + 1
|
||||
let itemEnd = match(a:list, ",", itemStart)
|
||||
let i = i + 1
|
||||
if (itemEnd == -1)
|
||||
if (i == a:n)
|
||||
let itemEnd = strlen(a:list)
|
||||
endif
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
if (itemEnd != -1)
|
||||
let item = strpart(a:list, itemStart, itemEnd - itemStart)
|
||||
endif
|
||||
return item
|
||||
endfunction
|
||||
|
||||
" Function : ExpandAlternatePath (PRIVATE)
|
||||
" Purpose : Expand path info. A path with a prefix of "wdr:" will be
|
||||
" treated as relative to the working directory (i.e. the
|
||||
" directory where vim was started.) A path prefix of "abs:" will
|
||||
" be treated as absolute. No prefix or "sfr:" will result in the
|
||||
" path being treated as relative to the source file (see sfPath
|
||||
" argument).
|
||||
"
|
||||
" A prefix of "reg:" will treat the pathSpec as a regular
|
||||
" expression substitution that is applied to the source file
|
||||
" path. The format is:
|
||||
"
|
||||
" reg:<sep><pattern><sep><subst><sep><flag><sep>
|
||||
"
|
||||
" <sep> seperator character, we often use one of [/|%#]
|
||||
" <pattern> is what you are looking for
|
||||
" <subst> is the output pattern
|
||||
" <flag> can be g for global replace or empty
|
||||
"
|
||||
" EXAMPLE: 'reg:/inc/src/g/' will replace every instance
|
||||
" of 'inc' with 'src' in the source file path. It is possible
|
||||
" to use match variables so you could do something like:
|
||||
" 'reg:|src/\([^/]*\)|inc/\1||' (see 'help :substitute',
|
||||
" 'help pattern' and 'help sub-replace-special' for more details
|
||||
"
|
||||
" NOTE: a.vim uses ',' (comma) internally so DON'T use it
|
||||
" in your regular expressions or other pathSpecs unless you update
|
||||
" the rest of the a.vim code to use some other seperator.
|
||||
"
|
||||
" Args : pathSpec -- path component (or substitution patterns)
|
||||
" sfPath -- source file path
|
||||
" Returns : a path that can be used by AlternateFile()
|
||||
" Author : Bindu Wavell <bindu@wavell.net>
|
||||
function! <SID>ExpandAlternatePath(pathSpec, sfPath)
|
||||
let prfx = strpart(a:pathSpec, 0, 4)
|
||||
if (prfx == "wdr:" || prfx == "abs:")
|
||||
let path = strpart(a:pathSpec, 4)
|
||||
elseif (prfx == "reg:")
|
||||
let re = strpart(a:pathSpec, 4)
|
||||
let sep = strpart(re, 0, 1)
|
||||
let patend = match(re, sep, 1)
|
||||
let pat = strpart(re, 1, patend - 1)
|
||||
let subend = match(re, sep, patend + 1)
|
||||
let sub = strpart(re, patend+1, subend - patend - 1)
|
||||
let flag = strpart(re, strlen(re) - 2)
|
||||
if (flag == sep)
|
||||
let flag = ''
|
||||
endif
|
||||
let path = substitute(a:sfPath, pat, sub, flag)
|
||||
"call confirm('PAT: [' . pat . '] SUB: [' . sub . ']')
|
||||
"call confirm(a:sfPath . ' => ' . path)
|
||||
else
|
||||
let path = a:pathSpec
|
||||
if (prfx == "sfr:")
|
||||
let path = strpart(path, 4)
|
||||
endif
|
||||
let path = a:sfPath . "/" . path
|
||||
endif
|
||||
return path
|
||||
endfunction
|
||||
|
||||
" Function : FindFileInSearchPath (PRIVATE)
|
||||
" Purpose : Searches for a file in the search path list
|
||||
" Args : filename -- name of the file to search for
|
||||
" pathList -- the path list to search
|
||||
" relPathBase -- the path which relative paths are expanded from
|
||||
" Returns : An expanded filename if found, the empty string otherwise
|
||||
" Author : Michael Sharpe (feline@irendi.com)
|
||||
" History : inline code written by Bindu Wavell originally
|
||||
function! <SID>FindFileInSearchPath(fileName, pathList, relPathBase)
|
||||
let filepath = ""
|
||||
let m = 1
|
||||
let pathListLen = strlen(a:pathList)
|
||||
if (pathListLen > 0)
|
||||
while (1)
|
||||
let pathSpec = <SID>GetNthItemFromList(a:pathList, m)
|
||||
if (pathSpec != "")
|
||||
let path = <SID>ExpandAlternatePath(pathSpec, a:relPathBase)
|
||||
let fullname = path . "/" . a:fileName
|
||||
let foundMatch = <SID>BufferOrFileExists(fullname)
|
||||
if (foundMatch)
|
||||
let filepath = fullname
|
||||
break
|
||||
endif
|
||||
else
|
||||
break
|
||||
endif
|
||||
let m = m + 1
|
||||
endwhile
|
||||
endif
|
||||
return filepath
|
||||
endfunction
|
||||
|
||||
" Function : FindFileInSearchPathEx (PRIVATE)
|
||||
" Purpose : Searches for a file in the search path list
|
||||
" Args : filename -- name of the file to search for
|
||||
" pathList -- the path list to search
|
||||
" relPathBase -- the path which relative paths are expanded from
|
||||
" count -- find the count'th occurence of the file on the path
|
||||
" Returns : An expanded filename if found, the empty string otherwise
|
||||
" Author : Michael Sharpe (feline@irendi.com)
|
||||
" History : Based on <SID>FindFileInSearchPath() but with extensions
|
||||
function! <SID>FindFileInSearchPathEx(fileName, pathList, relPathBase, count)
|
||||
let filepath = ""
|
||||
let m = 1
|
||||
let spath = ""
|
||||
let pathListLen = strlen(a:pathList)
|
||||
if (pathListLen > 0)
|
||||
while (1)
|
||||
let pathSpec = <SID>GetNthItemFromList(a:pathList, m)
|
||||
if (pathSpec != "")
|
||||
let path = <SID>ExpandAlternatePath(pathSpec, a:relPathBase)
|
||||
if (spath != "")
|
||||
let spath = spath . ','
|
||||
endif
|
||||
let spath = spath . path
|
||||
else
|
||||
break
|
||||
endif
|
||||
let m = m + 1
|
||||
endwhile
|
||||
endif
|
||||
|
||||
if (&path != "")
|
||||
if (spath != "")
|
||||
let spath = spath . ','
|
||||
endif
|
||||
let spath = spath . &path
|
||||
endif
|
||||
|
||||
let filepath = findfile(a:fileName, spath, a:count)
|
||||
return filepath
|
||||
endfunction
|
||||
|
||||
" Function : EnumerateFilesByExtension (PRIVATE)
|
||||
" Purpose : enumerates all files by a particular list of alternate extensions.
|
||||
" Args : path -- path of a file (not including the file)
|
||||
" baseName -- base name of the file to be expanded
|
||||
" extension -- extension whose alternates are to be enumerated
|
||||
" Returns : comma separated list of files with extensions
|
||||
" Author : Michael Sharpe <feline@irendi.com>
|
||||
function! EnumerateFilesByExtension(path, baseName, extension)
|
||||
let enumeration = ""
|
||||
let extSpec = ""
|
||||
let v:errmsg = ""
|
||||
silent! echo g:alternateExtensions_{a:extension}
|
||||
if (v:errmsg == "")
|
||||
let extSpec = g:alternateExtensions_{a:extension}
|
||||
endif
|
||||
if (extSpec == "")
|
||||
if (has_key(g:alternateExtensionsDict, a:extension))
|
||||
let extSpec = g:alternateExtensionsDict[a:extension]
|
||||
endif
|
||||
endif
|
||||
if (extSpec != "")
|
||||
let n = 1
|
||||
let done = 0
|
||||
while (!done)
|
||||
let ext = <SID>GetNthItemFromList(extSpec, n)
|
||||
if (ext != "")
|
||||
if (a:path != "")
|
||||
let newFilename = a:path . "/" . a:baseName . "." . ext
|
||||
else
|
||||
let newFilename = a:baseName . "." . ext
|
||||
endif
|
||||
if (enumeration == "")
|
||||
let enumeration = newFilename
|
||||
else
|
||||
let enumeration = enumeration . "," . newFilename
|
||||
endif
|
||||
else
|
||||
let done = 1
|
||||
endif
|
||||
let n = n + 1
|
||||
endwhile
|
||||
endif
|
||||
return enumeration
|
||||
endfunction
|
||||
|
||||
" Function : EnumerateFilesByExtensionInPath (PRIVATE)
|
||||
" Purpose : enumerates all files by expanding the path list and the extension
|
||||
" list.
|
||||
" Args : baseName -- base name of the file
|
||||
" extension -- extension whose alternates are to be enumerated
|
||||
" pathList -- the list of paths to enumerate
|
||||
" relPath -- the path of the current file for expansion of relative
|
||||
" paths in the path list.
|
||||
" Returns : A comma separated list of paths with extensions
|
||||
" Author : Michael Sharpe <feline@irendi.com>
|
||||
function! EnumerateFilesByExtensionInPath(baseName, extension, pathList, relPathBase)
|
||||
let enumeration = ""
|
||||
let filepath = ""
|
||||
let m = 1
|
||||
let pathListLen = strlen(a:pathList)
|
||||
if (pathListLen > 0)
|
||||
while (1)
|
||||
let pathSpec = <SID>GetNthItemFromList(a:pathList, m)
|
||||
if (pathSpec != "")
|
||||
let path = <SID>ExpandAlternatePath(pathSpec, a:relPathBase)
|
||||
let pe = EnumerateFilesByExtension(path, a:baseName, a:extension)
|
||||
if (enumeration == "")
|
||||
let enumeration = pe
|
||||
else
|
||||
let enumeration = enumeration . "," . pe
|
||||
endif
|
||||
else
|
||||
break
|
||||
endif
|
||||
let m = m + 1
|
||||
endwhile
|
||||
endif
|
||||
return enumeration
|
||||
endfunction
|
||||
|
||||
" Function : DetermineExtension (PRIVATE)
|
||||
" Purpose : Determines the extension of a filename based on the register
|
||||
" alternate extension. This allow extension which contain dots to
|
||||
" be considered. E.g. foo.aspx.cs to foo.aspx where an alternate
|
||||
" exists for the aspx.cs extension. Note that this will only accept
|
||||
" extensions which contain less than 5 dots. This is only
|
||||
" implemented in this manner for simplicity...it is doubtful that
|
||||
" this will be a restriction in non-contrived situations.
|
||||
" Args : The path to the file to find the extension in
|
||||
" Returns : The matched extension if any
|
||||
" Author : Michael Sharpe (feline@irendi.com)
|
||||
" History : idea from Tom-Erik Duestad
|
||||
" Notes : there is some magic occuring here. The exists() function does not
|
||||
" work well when the curly brace variable has dots in it. And why
|
||||
" should it, dots are not valid in variable names. But the exists
|
||||
" function is wierd too. Lets say foo_c does exist. Then
|
||||
" exists("foo_c.e.f") will be true...even though the variable does
|
||||
" not exist. However the curly brace variables do work when the
|
||||
" variable has dots in it. E.g foo_{'c'} is different from
|
||||
" foo_{'c.d.e'}...and foo_{'c'} is identical to foo_c and
|
||||
" foo_{'c.d.e'} is identical to foo_c.d.e right? Yes in the current
|
||||
" implementation of vim. To trick vim to test for existence of such
|
||||
" variables echo the curly brace variable and look for an error
|
||||
" message.
|
||||
function! DetermineExtension(path)
|
||||
let mods = ":t"
|
||||
let i = 0
|
||||
while i <= s:maxDotsInExtension
|
||||
let mods = mods . ":e"
|
||||
let extension = fnamemodify(a:path, mods)
|
||||
if (has_key(g:alternateExtensionsDict, extension))
|
||||
return extension
|
||||
endif
|
||||
let v:errmsg = ""
|
||||
silent! echo g:alternateExtensions_{extension}
|
||||
if (v:errmsg == "")
|
||||
return extension
|
||||
endif
|
||||
let i = i + 1
|
||||
endwhile
|
||||
return ""
|
||||
endfunction
|
||||
|
||||
" Function : AlternateFile (PUBLIC)
|
||||
" Purpose : Opens a new buffer by looking at the extension of the current
|
||||
" buffer and finding the corresponding file. E.g. foo.c <--> foo.h
|
||||
" Args : accepts one argument. If present it used the argument as the new
|
||||
" extension.
|
||||
" Returns : nothing
|
||||
" Author : Michael Sharpe <feline@irendi.com>
|
||||
" History : + When an alternate can't be found in the same directory as the
|
||||
" source file, a search path will be traversed looking for the
|
||||
" alternates.
|
||||
" + Moved some code into a separate function, minor optimization
|
||||
" + rework to favor files in memory based on complete enumeration of
|
||||
" all files extensions and paths
|
||||
function! AlternateFile(splitWindow, ...)
|
||||
let extension = DetermineExtension(expand("%:p"))
|
||||
let baseName = substitute(expand("%:t"), "\." . extension . '$', "", "")
|
||||
let currentPath = expand("%:p:h")
|
||||
|
||||
if (a:0 != 0)
|
||||
let newFullname = currentPath . "/" . baseName . "." . a:1
|
||||
call <SID>FindOrCreateBuffer(newFullname, a:splitWindow, 0)
|
||||
else
|
||||
let allfiles = ""
|
||||
if (extension != "")
|
||||
let allfiles1 = EnumerateFilesByExtension(currentPath, baseName, extension)
|
||||
let allfiles2 = EnumerateFilesByExtensionInPath(baseName, extension, g:alternateSearchPath, currentPath)
|
||||
|
||||
if (allfiles1 != "")
|
||||
if (allfiles2 != "")
|
||||
let allfiles = allfiles1 . ',' . allfiles2
|
||||
else
|
||||
let allfiles = allfiles1
|
||||
endif
|
||||
else
|
||||
let allfiles = allfiles2
|
||||
endif
|
||||
endif
|
||||
|
||||
if (allfiles != "")
|
||||
let bestFile = ""
|
||||
let bestScore = 0
|
||||
let score = 0
|
||||
let n = 1
|
||||
|
||||
let onefile = <SID>GetNthItemFromList(allfiles, n)
|
||||
let bestFile = onefile
|
||||
while (onefile != "" && score < 2)
|
||||
let score = <SID>BufferOrFileExists(onefile)
|
||||
if (score > bestScore)
|
||||
let bestScore = score
|
||||
let bestFile = onefile
|
||||
endif
|
||||
let n = n + 1
|
||||
let onefile = <SID>GetNthItemFromList(allfiles, n)
|
||||
endwhile
|
||||
|
||||
if (bestScore == 0 && g:alternateNoDefaultAlternate == 1)
|
||||
echo "No existing alternate available"
|
||||
else
|
||||
call <SID>FindOrCreateBuffer(bestFile, a:splitWindow, 1)
|
||||
let b:AlternateAllFiles = allfiles
|
||||
endif
|
||||
else
|
||||
echo "No alternate file/buffer available"
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function : AlternateOpenFileUnderCursor (PUBLIC)
|
||||
" Purpose : Opens file under the cursor
|
||||
" Args : splitWindow -- indicates how to open the file
|
||||
" Returns : Nothing
|
||||
" Author : Michael Sharpe (feline@irendi.com) www.irendi.com
|
||||
function! AlternateOpenFileUnderCursor(splitWindow,...)
|
||||
let cursorFile = (a:0 > 0) ? a:1 : expand("<cfile>")
|
||||
let currentPath = expand("%:p:h")
|
||||
let openCount = 1
|
||||
|
||||
let fileName = <SID>FindFileInSearchPathEx(cursorFile, g:alternateSearchPath, currentPath, openCount)
|
||||
if (fileName != "")
|
||||
call <SID>FindOrCreateBuffer(fileName, a:splitWindow, 1)
|
||||
let b:openCount = openCount
|
||||
let b:cursorFile = cursorFile
|
||||
let b:currentPath = currentPath
|
||||
else
|
||||
echo "Can't find file"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function : AlternateOpenNextFile (PUBLIC)
|
||||
" Purpose : Opens the next file corresponding to the search which found the
|
||||
" current file
|
||||
" Args : bang -- indicates what to do if the current file has not been
|
||||
" saved
|
||||
" Returns : nothing
|
||||
" Author : Michael Sharpe (feline@irendi.com) www.irendi.com
|
||||
function! AlternateOpenNextFile(bang)
|
||||
let cursorFile = ""
|
||||
if (exists("b:cursorFile"))
|
||||
let cursorFile = b:cursorFile
|
||||
endif
|
||||
|
||||
let currentPath = ""
|
||||
if (exists("b:currentPath"))
|
||||
let currentPath = b:currentPath
|
||||
endif
|
||||
|
||||
let openCount = 0
|
||||
if (exists("b:openCount"))
|
||||
let openCount = b:openCount + 1
|
||||
endif
|
||||
|
||||
if (cursorFile != "" && currentPath != "" && openCount != 0)
|
||||
let fileName = <SID>FindFileInSearchPathEx(cursorFile, g:alternateSearchPath, currentPath, openCount)
|
||||
if (fileName != "")
|
||||
call <SID>FindOrCreateBuffer(fileName, "n".a:bang, 0)
|
||||
let b:openCount = openCount
|
||||
let b:cursorFile = cursorFile
|
||||
let b:currentPath = currentPath
|
||||
else
|
||||
let fileName = <SID>FindFileInSearchPathEx(cursorFile, g:alternateSearchPath, currentPath, 1)
|
||||
if (fileName != "")
|
||||
call <SID>FindOrCreateBuffer(fileName, "n".a:bang, 0)
|
||||
let b:openCount = 1
|
||||
let b:cursorFile = cursorFile
|
||||
let b:currentPath = currentPath
|
||||
else
|
||||
echo "Can't find next file"
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
comm! -nargs=? -bang IH call AlternateOpenFileUnderCursor("n<bang>", <f-args>)
|
||||
comm! -nargs=? -bang IHS call AlternateOpenFileUnderCursor("h<bang>", <f-args>)
|
||||
comm! -nargs=? -bang IHV call AlternateOpenFileUnderCursor("v<bang>", <f-args>)
|
||||
comm! -nargs=? -bang IHT call AlternateOpenFileUnderCursor("t<bang>", <f-args>)
|
||||
comm! -nargs=? -bang IHN call AlternateOpenNextFile("<bang>")
|
||||
imap <Leader>ih <ESC>:IHS<CR>
|
||||
nmap <Leader>ih :IHS<CR>
|
||||
imap <Leader>is <ESC>:IHS<CR>:A<CR>
|
||||
nmap <Leader>is :IHS<CR>:A<CR>
|
||||
imap <Leader>ihn <ESC>:IHN<CR>
|
||||
nmap <Leader>ihn :IHN<CR>
|
||||
|
||||
"function! <SID>PrintList(theList)
|
||||
" let n = 1
|
||||
" let oneFile = <SID>GetNthItemFromList(a:theList, n)
|
||||
" while (oneFile != "")
|
||||
" let n = n + 1
|
||||
" let oneFile = <SID>GetNthItemFromList(a:theList, n)
|
||||
" endwhile
|
||||
"endfunction
|
||||
|
||||
" Function : NextAlternate (PUBLIC)
|
||||
" Purpose : Used to cycle through any other alternate file which existed on
|
||||
" the search path.
|
||||
" Args : bang (IN) - used to implement the AN vs AN! functionality
|
||||
" Returns : nothing
|
||||
" Author : Michael Sharpe <feline@irendi.com>
|
||||
function! NextAlternate(bang)
|
||||
if (exists('b:AlternateAllFiles'))
|
||||
let currentFile = expand("%")
|
||||
let n = 1
|
||||
let onefile = <SID>GetNthItemFromList(b:AlternateAllFiles, n)
|
||||
while (onefile != "" && !<SID>EqualFilePaths(fnamemodify(onefile,":p"), fnamemodify(currentFile,":p")))
|
||||
let n = n + 1
|
||||
let onefile = <SID>GetNthItemFromList(b:AlternateAllFiles, n)
|
||||
endwhile
|
||||
|
||||
if (onefile != "")
|
||||
let stop = n
|
||||
let n = n + 1
|
||||
let foundAlternate = 0
|
||||
let nextAlternate = ""
|
||||
while (n != stop)
|
||||
let nextAlternate = <SID>GetNthItemFromList(b:AlternateAllFiles, n)
|
||||
if (nextAlternate == "")
|
||||
let n = 1
|
||||
continue
|
||||
endif
|
||||
let n = n + 1
|
||||
if (<SID>EqualFilePaths(fnamemodify(nextAlternate, ":p"), fnamemodify(currentFile, ":p")))
|
||||
continue
|
||||
endif
|
||||
if (filereadable(nextAlternate))
|
||||
" on cygwin filereadable("foo.H") returns true if "foo.h" exists
|
||||
if (has("unix") && $WINDIR != "" && fnamemodify(nextAlternate, ":p") ==? fnamemodify(currentFile, ":p"))
|
||||
continue
|
||||
endif
|
||||
let foundAlternate = 1
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
if (foundAlternate == 1)
|
||||
let s:AlternateAllFiles = b:AlternateAllFiles
|
||||
"silent! execute ":e".a:bang." " . nextAlternate
|
||||
call <SID>FindOrCreateBuffer(nextAlternate, "n".a:bang, 0)
|
||||
let b:AlternateAllFiles = s:AlternateAllFiles
|
||||
else
|
||||
echo "Only this alternate file exists"
|
||||
endif
|
||||
else
|
||||
echo "Could not find current file in alternates list"
|
||||
endif
|
||||
else
|
||||
echo "No other alternate files exist"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
comm! -nargs=? -bang A call AlternateFile("n<bang>", <f-args>)
|
||||
comm! -nargs=? -bang AS call AlternateFile("h<bang>", <f-args>)
|
||||
comm! -nargs=? -bang AV call AlternateFile("v<bang>", <f-args>)
|
||||
comm! -nargs=? -bang AT call AlternateFile("t<bang>", <f-args>)
|
||||
comm! -nargs=? -bang AN call NextAlternate("<bang>")
|
||||
|
||||
" Function : BufferOrFileExists (PRIVATE)
|
||||
" Purpose : determines if a buffer or a readable file exists
|
||||
" Args : fileName (IN) - name of the file to check
|
||||
" Returns : 2 if it exists in memory, 1 if it exists, 0 otherwise
|
||||
" Author : Michael Sharpe <feline@irendi.com>
|
||||
" History : Updated code to handle buffernames using just the
|
||||
" filename and not the path.
|
||||
function! <SID>BufferOrFileExists(fileName)
|
||||
let result = 0
|
||||
|
||||
let lastBuffer = bufnr("$")
|
||||
let i = 1
|
||||
while i <= lastBuffer
|
||||
if <SID>EqualFilePaths(expand("#".i.":p"), a:fileName)
|
||||
let result = 2
|
||||
break
|
||||
endif
|
||||
let i = i + 1
|
||||
endwhile
|
||||
|
||||
if (!result)
|
||||
let bufName = fnamemodify(a:fileName,":t")
|
||||
let memBufName = bufname(bufName)
|
||||
if (memBufName != "")
|
||||
let memBufBasename = fnamemodify(memBufName, ":t")
|
||||
if (bufName == memBufBasename)
|
||||
let result = 2
|
||||
endif
|
||||
endif
|
||||
|
||||
if (!result)
|
||||
let result = bufexists(bufName) || bufexists(a:fileName) || filereadable(a:fileName)
|
||||
endif
|
||||
endif
|
||||
|
||||
if (!result)
|
||||
let result = filereadable(a:fileName)
|
||||
endif
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" Function : FindOrCreateBuffer (PRIVATE)
|
||||
" Purpose : searches the buffer list (:ls) for the specified filename. If
|
||||
" found, checks the window list for the buffer. If the buffer is in
|
||||
" an already open window, it switches to the window. If the buffer
|
||||
" was not in a window, it switches to that buffer. If the buffer did
|
||||
" not exist, it creates it.
|
||||
" Args : filename (IN) -- the name of the file
|
||||
" doSplit (IN) -- indicates whether the window should be split
|
||||
" ("v", "h", "n", "v!", "h!", "n!", "t", "t!")
|
||||
" findSimilar (IN) -- indicate weather existing buffers should be
|
||||
" prefered
|
||||
" Returns : nothing
|
||||
" Author : Michael Sharpe <feline@irendi.com>
|
||||
" History : + bufname() was not working very well with the possibly strange
|
||||
" paths that can abound with the search path so updated this
|
||||
" slightly. -- Bindu
|
||||
" + updated window switching code to make it more efficient -- Bindu
|
||||
" Allow ! to be applied to buffer/split/editing commands for more
|
||||
" vim/vi like consistency
|
||||
" + implemented fix from Matt Perry
|
||||
function! <SID>FindOrCreateBuffer(fileName, doSplit, findSimilar)
|
||||
" Check to see if the buffer is already open before re-opening it.
|
||||
let FILENAME = escape(a:fileName, ' ')
|
||||
let bufNr = -1
|
||||
let lastBuffer = bufnr("$")
|
||||
let i = 1
|
||||
if (a:findSimilar)
|
||||
while i <= lastBuffer
|
||||
if <SID>EqualFilePaths(expand("#".i.":p"), a:fileName)
|
||||
let bufNr = i
|
||||
break
|
||||
endif
|
||||
let i = i + 1
|
||||
endwhile
|
||||
|
||||
if (bufNr == -1)
|
||||
let bufName = bufname(a:fileName)
|
||||
let bufFilename = fnamemodify(a:fileName,":t")
|
||||
|
||||
if (bufName == "")
|
||||
let bufName = bufname(bufFilename)
|
||||
endif
|
||||
|
||||
if (bufName != "")
|
||||
let tail = fnamemodify(bufName, ":t")
|
||||
if (tail != bufFilename)
|
||||
let bufName = ""
|
||||
endif
|
||||
endif
|
||||
if (bufName != "")
|
||||
let bufNr = bufnr(bufName)
|
||||
let FILENAME = bufName
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if (g:alternateRelativeFiles == 1)
|
||||
let FILENAME = fnamemodify(FILENAME, ":p:.")
|
||||
endif
|
||||
|
||||
let splitType = a:doSplit[0]
|
||||
let bang = a:doSplit[1]
|
||||
if (bufNr == -1)
|
||||
" Buffer did not exist....create it
|
||||
let v:errmsg=""
|
||||
if (splitType == "h")
|
||||
silent! execute ":split".bang." " . FILENAME
|
||||
elseif (splitType == "v")
|
||||
silent! execute ":vsplit".bang." " . FILENAME
|
||||
elseif (splitType == "t")
|
||||
silent! execute ":tab split".bang." " . FILENAME
|
||||
else
|
||||
silent! execute ":e".bang." " . FILENAME
|
||||
endif
|
||||
if (v:errmsg != "")
|
||||
echo v:errmsg
|
||||
endif
|
||||
else
|
||||
|
||||
" Find the correct tab corresponding to the existing buffer
|
||||
let tabNr = -1
|
||||
" iterate tab pages
|
||||
for i in range(tabpagenr('$'))
|
||||
" get the list of buffers in the tab
|
||||
let tabList = tabpagebuflist(i + 1)
|
||||
let idx = 0
|
||||
" iterate each buffer in the list
|
||||
while idx < len(tabList)
|
||||
" if it matches the buffer we are looking for...
|
||||
if (tabList[idx] == bufNr)
|
||||
" ... save the number
|
||||
let tabNr = i + 1
|
||||
break
|
||||
endif
|
||||
let idx = idx + 1
|
||||
endwhile
|
||||
if (tabNr != -1)
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
" switch the the tab containing the buffer
|
||||
if (tabNr != -1)
|
||||
execute "tabn ".tabNr
|
||||
endif
|
||||
|
||||
" Buffer was already open......check to see if it is in a window
|
||||
let bufWindow = bufwinnr(bufNr)
|
||||
if (bufWindow == -1)
|
||||
" Buffer was not in a window so open one
|
||||
let v:errmsg=""
|
||||
if (splitType == "h")
|
||||
silent! execute ":sbuffer".bang." " . FILENAME
|
||||
elseif (splitType == "v")
|
||||
silent! execute ":vert sbuffer " . FILENAME
|
||||
elseif (splitType == "t")
|
||||
silent! execute ":tab sbuffer " . FILENAME
|
||||
else
|
||||
silent! execute ":buffer".bang." " . FILENAME
|
||||
endif
|
||||
if (v:errmsg != "")
|
||||
echo v:errmsg
|
||||
endif
|
||||
else
|
||||
" Buffer is already in a window so switch to the window
|
||||
execute bufWindow."wincmd w"
|
||||
if (bufWindow != winnr())
|
||||
" something wierd happened...open the buffer
|
||||
let v:errmsg=""
|
||||
if (splitType == "h")
|
||||
silent! execute ":split".bang." " . FILENAME
|
||||
elseif (splitType == "v")
|
||||
silent! execute ":vsplit".bang." " . FILENAME
|
||||
elseif (splitType == "t")
|
||||
silent! execute ":tab split".bang." " . FILENAME
|
||||
else
|
||||
silent! execute ":e".bang." " . FILENAME
|
||||
endif
|
||||
if (v:errmsg != "")
|
||||
echo v:errmsg
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function : EqualFilePaths (PRIVATE)
|
||||
" Purpose : Compares two paths. Do simple string comparison anywhere but on
|
||||
" Windows. On Windows take into account that file paths could differ
|
||||
" in usage of separators and the fact that case does not matter.
|
||||
" "c:\WINDOWS" is the same path as "c:/windows". has("win32unix") Vim
|
||||
" version does not count as one having Windows path rules.
|
||||
" Args : path1 (IN) -- first path
|
||||
" path2 (IN) -- second path
|
||||
" Returns : 1 if path1 is equal to path2, 0 otherwise.
|
||||
" Author : Ilya Bobir <ilya@po4ta.com>
|
||||
function! <SID>EqualFilePaths(path1, path2)
|
||||
if has("win16") || has("win32") || has("win64") || has("win95")
|
||||
return substitute(a:path1, "\/", "\\", "g") ==? substitute(a:path2, "\/", "\\", "g")
|
||||
else
|
||||
return a:path1 == a:path2
|
||||
endif
|
||||
endfunction
|
@ -1,524 +0,0 @@
|
||||
" Buffet Plugin for VIM > 7.3 version 2.10
|
||||
"
|
||||
" A fast, simple and easy to use pluggin for switching and managing buffers.
|
||||
"
|
||||
" Usage:
|
||||
"
|
||||
" Copy the file buffet.vim to the plugins directory.
|
||||
" The command to open the buffer list is
|
||||
" :Bufferlist
|
||||
"
|
||||
" A horizontal window is opened with a list of buffer. the buffer numbers are
|
||||
" also displayed along side. The user select a buffer by
|
||||
"
|
||||
" 1.Entering the buffer number using keyboard. Just start typing the number using keyboard.
|
||||
" The plugin will search for the buffer with that number and will keep going to the matching
|
||||
" buffers. Entered number will be shown at the top you can use backspace to edit it.When you
|
||||
" are in the desired buffer, press enter or any control keys that are
|
||||
" displayed at the bottom to execute any command available, on that buffer
|
||||
"
|
||||
" Available commands
|
||||
"
|
||||
" Enter(Replace current buffer)
|
||||
" o - make window fill with selected buffer
|
||||
" hh - (Horizontal Split)
|
||||
" v - (Vertical Split)
|
||||
" - - (Vertical Diff Split)
|
||||
" g - (Go to buffer window if it is visible in any tab)
|
||||
" d - (Delete selected buffer)
|
||||
" x - (Close window)
|
||||
" c - (Clear diff flags for all windows)
|
||||
"
|
||||
" 2.Move up or down using the navigation keys to reach the buffer line.
|
||||
"
|
||||
" 3.Doubleclick on a buffer line using the mouse. Will immediatly switch to
|
||||
" that buffer
|
||||
"
|
||||
" To make this plugin really useful you have to assign a shortcut key for it,
|
||||
" say you want F2 key to open the buffer list. you can add the following line in your .vimrc file.
|
||||
"
|
||||
" map <F2> :Bufferlist<CR>
|
||||
"
|
||||
" Last Change: 2012 Jan
|
||||
" Maintainer: Sandeep.c.r<sandeepcr2@gmail.com>
|
||||
"
|
||||
"
|
||||
function! s:open_new_window(dim)
|
||||
exe s:currentposition. ' '.a:dim . 'new buflisttempbuffer412393'
|
||||
set nonu
|
||||
setlocal bt=nofile
|
||||
setlocal modifiable
|
||||
setlocal bt=nowrite
|
||||
setlocal bufhidden=hide
|
||||
setlocal noswapfile
|
||||
setlocal nowrap
|
||||
setlocal ft=buffet
|
||||
return bufnr('%')
|
||||
endfunction
|
||||
function! s:open_new_vertical_window(dim)
|
||||
exe a:dim . 'vnew'
|
||||
set nonu
|
||||
setlocal bt=nofile
|
||||
setlocal bt=nowrite
|
||||
setlocal bufhidden=hide
|
||||
setlocal noswapfile
|
||||
return bufnr('%')
|
||||
endfunction
|
||||
function! s:cursormove()
|
||||
let s:lineonclose = line('.')
|
||||
if(s:lineonclose >len(s:displayed)+1)
|
||||
call cursor(2,3)
|
||||
elseif(s:lineonclose ==1 )
|
||||
call cursor(len(s:displayed)+1,3)
|
||||
endif
|
||||
endfunction
|
||||
function! s:buffet_pathshorten(str)
|
||||
if(s:detail == 1)
|
||||
return a:str
|
||||
else
|
||||
return pathshorten(a:str)
|
||||
endif
|
||||
endfunction
|
||||
function! s:display_buffer_list(gotolastbuffer)
|
||||
let l:line = 2
|
||||
let l:fg = synIDattr(hlID('Statement'),'fg','gui')
|
||||
let l:bg = synIDattr(hlID('CursorLine'),'bg','gui')
|
||||
call filter(s:bufrecent,'exists("s:bufferlistlite[v:val]") && v:val!=t:tlistbuf' )
|
||||
let l:maxlen = 0
|
||||
let l:headmaxlen = 0
|
||||
for l:i in keys(s:bufferlistlite)
|
||||
if(index(s:bufrecent,l:i)==-1)
|
||||
call add(s:bufrecent,l:i)
|
||||
endif
|
||||
let l:temp = strlen(fnamemodify(s:bufferlistlite[l:i],':t'))
|
||||
let l:headtemp = strlen(s:buffet_pathshorten(fnamemodify(s:bufferlistlite[l:i],':h')))
|
||||
if(l:headtemp > l:headmaxlen)
|
||||
let l:headmaxlen = l:headtemp
|
||||
endif
|
||||
if(l:temp > l:maxlen)
|
||||
let l:maxlen = l:temp
|
||||
endif
|
||||
endfor
|
||||
call setline(1,"Buffet-2.10 ( Enter Number to search for a buffer number )")
|
||||
let s:displayed = []
|
||||
let s:last_buffer_line = 0
|
||||
for l:i in s:bufrecent
|
||||
let l:thisbufno = str2nr(l:i)
|
||||
let l:bufname = s:bufferlistlite[l:i]
|
||||
let l:buftailname =fnamemodify(l:bufname,':t')
|
||||
let l:bufheadlname =s:buffet_pathshorten(fnamemodify(l:bufname,':h'))
|
||||
if(getbufvar(l:thisbufno,'&modified'))
|
||||
let l:modifiedflag = " (+) "
|
||||
else
|
||||
let l:modifiedflag = " "
|
||||
endif
|
||||
let l:padlength = l:maxlen - strlen(l:buftailname) + 2
|
||||
let l:padlengthhead= l:headmaxlen - strlen(l:bufheadlname) + 2
|
||||
let l:short_file_name = repeat(' ',2-strlen(l:i)).l:i .' '. l:buftailname.repeat(' ',l:padlength) .l:modifiedflag. l:bufheadlname .repeat(' ',l:padlengthhead)
|
||||
let l:padstring = repeat(' ',len(l:short_file_name))
|
||||
if(exists("s:buftotabwindow[l:thisbufno]"))
|
||||
let l:thistab = s:buftotabwindow[l:thisbufno][0][0]
|
||||
let l:thiswindow = s:buftotabwindow[l:thisbufno][0][1]
|
||||
let l:short_file_name = l:short_file_name ." Tab:".l:thistab." Window:".l:thiswindow
|
||||
call add(s:displayed,[l:thisbufno,l:thistab,l:thiswindow])
|
||||
if(l:thistab == s:sourcetab && l:thiswindow == s:sourcewindow)
|
||||
let l:short_file_name = '>'.l:short_file_name ." <"
|
||||
else
|
||||
let l:short_file_name = ' '.l:short_file_name
|
||||
endif
|
||||
else
|
||||
let l:short_file_name = ' '.l:short_file_name
|
||||
call add(s:displayed,[l:thisbufno])
|
||||
endif
|
||||
call setline(l:line,l:short_file_name)
|
||||
let l:subwindow = 1
|
||||
while(exists("s:buftotabwindow[l:thisbufno][l:subwindow]"))
|
||||
let l:thistab = s:buftotabwindow[l:thisbufno][l:subwindow][0]
|
||||
let l:thiswindow = s:buftotabwindow[l:thisbufno][l:subwindow][1]
|
||||
let l:line += 1
|
||||
if(l:thistab == s:sourcetab && l:thiswindow == s:sourcewindow)
|
||||
call setline(l:line,'> '.l:padstring."Tab:".l:thistab." window:".l:thiswindow." <")
|
||||
else
|
||||
call setline(l:line,' '.l:padstring."Tab:".l:thistab." window:".l:thiswindow)
|
||||
endif
|
||||
call add(s:displayed,[l:thisbufno,l:thistab,l:thiswindow])
|
||||
let l:subwindow += 1
|
||||
endwhile
|
||||
if(s:last_buffer_line == 0)
|
||||
let s:last_buffer_line = l:line+1
|
||||
endif
|
||||
let l:line += 1
|
||||
endfor
|
||||
exe "resize ".(len(s:displayed)+4)
|
||||
call setline(l:line,"")
|
||||
let l:line+=1
|
||||
call setline(l:line,"Enter(Load buffer) | hh/v/-/c (Horizontal/Vertical/Vertical Diff Split/Clear Diff) | o(Maximize) | t(New tab) | m(Toggle detail) | g(Go to window) | d(Delete buffer) | x(Close window) ")
|
||||
let l:fg = synIDattr(hlID('Statement'),'fg','Question')
|
||||
exe 'highlight buffethelpline guibg=black'
|
||||
exe 'highlight buffethelpline guifg=orange'
|
||||
exe '2match buffethelpline /\%1l\|\%'.l:line.'l.\%>1c/'
|
||||
if(a:gotolastbuffer==1)
|
||||
call cursor(s:last_buffer_line,3)
|
||||
else
|
||||
if(s:lineonclose >len(s:displayed)+1)
|
||||
let s:lineonclose -=1
|
||||
endif
|
||||
call cursor(s:lineonclose,3)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:close()
|
||||
if(exists("t:tlistbuf"))
|
||||
unlet t:tlistbuf
|
||||
let s:lineonclose = line('.')
|
||||
:bdelete buflisttempbuffer412393
|
||||
echo ''
|
||||
exe s:sourcewindow. ' wincmd w'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:place_sign()
|
||||
setlocal cursorline
|
||||
return
|
||||
exec "sign unplace *"
|
||||
exec "sign define lineh linehl=Search texthl=Search"
|
||||
exec "sign place 10 name=lineh line=".line('.')." buffer=" . t:tlistbuf
|
||||
endfunction
|
||||
|
||||
function! s:getallbuffers()
|
||||
let l:buffers = filter(range(1,bufnr('$')), 'buflisted(v:val)')
|
||||
let l:return = {}
|
||||
for i in l:buffers
|
||||
let l:bufname = bufname(i)
|
||||
if(strlen(l:bufname)==0)
|
||||
let l:bufname = "[No Name]"
|
||||
endif
|
||||
let l:return[i] = l:bufname
|
||||
endfor
|
||||
return l:return
|
||||
endfunction
|
||||
|
||||
function! s:printmessage(msg)
|
||||
setlocal modifiable
|
||||
call setline(len(s:displayed)+2,a:msg)
|
||||
setlocal nomodifiable
|
||||
endfunction
|
||||
|
||||
function! s:press(num)
|
||||
if(a:num==-1)
|
||||
let s:keybuf = strpart(s:keybuf,0,len(s:keybuf)-1)
|
||||
else
|
||||
let s:keybuf = s:keybuf . a:num
|
||||
endif
|
||||
setlocal modifiable
|
||||
call setline(1 ,'Buffet-2.10 - Searching for buffer:'.s:keybuf.' (Use backspace to edit)')
|
||||
let l:index = 0
|
||||
for l:i in s:displayed
|
||||
if(l:i[0] == s:keybuf)
|
||||
let l:index += 2
|
||||
exe "normal "+l:index+ "gg"
|
||||
break
|
||||
endif
|
||||
let l:index += 1
|
||||
endfor
|
||||
setlocal nomodifiable
|
||||
endfunction
|
||||
|
||||
function! s:togglesw()
|
||||
let s:currentposition = ''
|
||||
call s:toggle(1)
|
||||
endfunction
|
||||
|
||||
function! s:toggletop()
|
||||
let s:currentposition = 'topleft'
|
||||
call s:toggle(1)
|
||||
endfunction
|
||||
function! s:toggle(gotolastbuffer)
|
||||
|
||||
let s:keybuf = ''
|
||||
if(exists("t:tlistbuf"))
|
||||
call s:close()
|
||||
return 0
|
||||
endif
|
||||
|
||||
let s:bufferlistlite = s:getallbuffers()
|
||||
let s:sourcebuffer = bufnr('%')
|
||||
let s:sourcewindow = winnr()
|
||||
let s:sourcetab = tabpagenr()
|
||||
let s:buftotabwindow = {}
|
||||
for l:i in range(tabpagenr('$'))
|
||||
let l:windowno = 1
|
||||
for l:bufno in tabpagebuflist(l:i + 1)
|
||||
if(!exists("s:buftotabwindow[l:bufno]"))
|
||||
let s:buftotabwindow[l:bufno] = []
|
||||
endif
|
||||
call add(s:buftotabwindow[l:bufno], [l:i+1,l:windowno])
|
||||
let l:windowno += 1
|
||||
endfor
|
||||
endfor
|
||||
let t:tlistbuf = s:open_new_window(len(s:bufrecent)+4)
|
||||
set nodiff
|
||||
set noscrollbind
|
||||
let s:buflistwindow = winnr()
|
||||
setlocal cursorline
|
||||
call s:display_buffer_list(a:gotolastbuffer)
|
||||
"call matchadd('String','[\/\\][^\/\\]*$')
|
||||
setlocal nomodifiable
|
||||
map <buffer> <silent> <2-leftrelease> :call <sid>loadbuffer(0)<cr>
|
||||
nnoremap <buffer> <silent> <C-R> :call <sid>loadbuffer(0)<cr>
|
||||
nnoremap <buffer> <silent> <C-M> :call <sid>loadbuffer(0)<cr>
|
||||
nnoremap <buffer> <silent> x :call <sid>closewindow(0)<cr>
|
||||
nnoremap <buffer> <silent> X :call <sid>closewindow(1)<cr>
|
||||
nnoremap <buffer> <silent> c :call <sid>cleardiff()<cr>
|
||||
nnoremap <buffer> <silent> C :call <sid>cleardiff()<cr>
|
||||
nnoremap <buffer> <silent> d :call <sid>deletebuffer(0)<cr>
|
||||
nnoremap <buffer> <silent> D :call <sid>deletebuffer(1)<cr>
|
||||
nnoremap <buffer> <silent> o :call <sid>loadbuffer(1)<cr>
|
||||
nnoremap <buffer> <silent> O :call <sid>loadbuffer(1)<cr>
|
||||
nnoremap <buffer> <silent> g :call <sid>gotowindow()<cr>
|
||||
nnoremap <buffer> <silent> G :call <sid>gotowindow()<cr>
|
||||
nnoremap <buffer> <silent> s :call <sid>split('h')<cr>
|
||||
nnoremap <buffer> <silent> S :call <sid>split('h')<cr>
|
||||
nnoremap <buffer> <silent> t :call <sid>openintab()<cr>
|
||||
nnoremap <buffer> <silent> T :call <sid>openintab()<cr>
|
||||
nnoremap <buffer> <silent> hh :call <sid>split('h')<cr>
|
||||
nnoremap <buffer> <silent> HH :call <sid>split('h')<cr>
|
||||
nnoremap <buffer> <silent> v :call <sid>split('v')<cr>
|
||||
nnoremap <buffer> <silent> V :call <sid>split('v')<cr>
|
||||
nnoremap <buffer> <silent> r :call <sid>refresh()<cr>
|
||||
nnoremap <buffer> <silent> 0 :call <sid>press(0)<cr>
|
||||
nnoremap <buffer> <silent> 1 :call <sid>press(1)<cr>
|
||||
nnoremap <buffer> <silent> 2 :call <sid>press(2)<cr>
|
||||
nnoremap <buffer> <silent> 3 :call <sid>press(3)<cr>
|
||||
nnoremap <buffer> <silent> 4 :call <sid>press(4)<cr>
|
||||
nnoremap <buffer> <silent> 5 :call <sid>press(5)<cr>
|
||||
nnoremap <buffer> <silent> 6 :call <sid>press(6)<cr>
|
||||
nnoremap <buffer> <silent> 7 :call <sid>press(7)<cr>
|
||||
nnoremap <buffer> <silent> 8 :call <sid>press(8)<cr>
|
||||
nnoremap <buffer> <silent> 9 :call <sid>press(9)<cr>
|
||||
nnoremap <buffer> <silent> - :call <sid>diff_split('v')<cr>
|
||||
nnoremap <buffer> <silent> m :call <sid>toggle_detail()<cr>
|
||||
nnoremap <buffer> <silent> M :call <sid>toggle_detail()<cr>
|
||||
nnoremap <buffer> <silent> <BS> :call <sid>press(-1)<cr>
|
||||
nnoremap <buffer> <silent> <Esc> :call <sid>close()<cr>
|
||||
augroup Tlistaco1
|
||||
autocmd!
|
||||
au BufLeave <buffer> call <sid>close()
|
||||
au CursorMoved <buffer> call <sid>cursormove()
|
||||
augroup END
|
||||
endfunction
|
||||
function! s:toggle_detail()
|
||||
let s:detail = !s:detail
|
||||
setlocal modifiable
|
||||
call s:display_buffer_list(0)
|
||||
setlocal nomodifiable
|
||||
endfunction
|
||||
function! s:cleardiff()
|
||||
for i in range(1,winnr('$'))
|
||||
call setwinvar(i,"&diff",0)
|
||||
call setwinvar(i,"&scrollbind",0)
|
||||
endfor
|
||||
endfunction
|
||||
function! s:deletebuffer(force)
|
||||
let l:llindex= line('.') - 2
|
||||
if(exists("s:displayed[l:llindex]") )
|
||||
let l:selectedbuffer = str2nr(s:displayed[l:llindex][0])
|
||||
if(getbufvar(str2nr(l:selectedbuffer),'&modified') && a:force == 0 )
|
||||
call s:printmessage("Buffer contents modified. Use 'D' to force delete.")
|
||||
else
|
||||
call s:toggle(0)
|
||||
exe "bdelete! ".l:selectedbuffer
|
||||
call s:toggle(0)
|
||||
endif
|
||||
else
|
||||
call s:close()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:openintab()
|
||||
let l:llindex= line('.') - 2
|
||||
if(exists("s:displayed[l:llindex]"))
|
||||
exe s:buflistwindow . ' wincmd w'
|
||||
let l:target = s:displayed[l:llindex][0]
|
||||
call s:close()
|
||||
exe "tabnew"
|
||||
exe l:target. ' buf!'
|
||||
else
|
||||
call s:close()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:closewindow(force)
|
||||
let l:llindex= line('.') - 2
|
||||
if(exists("s:displayed[l:llindex]"))
|
||||
if(exists("s:displayed[l:llindex][1]"))
|
||||
if(getbufvar(str2nr(s:displayed[l:llindex][0]),'&modified') && a:force == 0 )
|
||||
call s:printmessage("Buffer contents modified. Use 'X' to force close.")
|
||||
else
|
||||
if(tabpagenr('$')==1 && winnr('$')==2)
|
||||
call s:printmessage("Not closing last window of the last tab.")
|
||||
else
|
||||
exe s:buflistwindow . ' wincmd w'
|
||||
call s:close()
|
||||
exe "tabn" .s:displayed[l:llindex][1]
|
||||
exe s:displayed[l:llindex][2]. ' wincmd w'
|
||||
:q!
|
||||
exe "tabn". s:sourcetab
|
||||
call s:toggle(0)
|
||||
endif
|
||||
endif
|
||||
else
|
||||
call s:printmessage("Buffer not showing in any tab.")
|
||||
endif
|
||||
else
|
||||
call s:close()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:gotowindow()
|
||||
let l:llindex= line('.') - 2
|
||||
if(exists("s:displayed[l:llindex]"))
|
||||
if(exists("s:displayed[l:llindex][1]"))
|
||||
exe s:buflistwindow . ' wincmd w'
|
||||
call s:close()
|
||||
exe "tabn" .s:displayed[l:llindex][1]
|
||||
exe s:displayed[l:llindex][2]. ' wincmd w'
|
||||
else
|
||||
call s:printmessage("Buffer not showing in any tab. Use Enter,v,hh,t or o to open buffer in a window.")
|
||||
endif
|
||||
else
|
||||
call s:close()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:loadbuffer(isonly)
|
||||
let l:llindex= line('.') - 2
|
||||
if(exists("s:displayed[l:llindex]"))
|
||||
exe s:buflistwindow . ' wincmd w'
|
||||
let l:target = s:displayed[l:llindex][0]
|
||||
call s:close()
|
||||
call s:switch_buffer(l:target)
|
||||
if(a:isonly == 1 && winnr('$')>1)
|
||||
exe 'only!'
|
||||
endif
|
||||
else
|
||||
call s:close()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:diff_split(mode)
|
||||
let l:llindex= line('.') - 2
|
||||
if(exists("s:displayed[l:llindex]"))
|
||||
exe s:buflistwindow . ' wincmd w'
|
||||
let l:target = s:displayed[l:llindex][0]
|
||||
call s:close()
|
||||
call s:diff_split_buffer(l:target,a:mode)
|
||||
else
|
||||
call s:close()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:split(mode)
|
||||
let l:llindex= line('.') - 2
|
||||
if(exists("s:displayed[l:llindex]"))
|
||||
exe s:buflistwindow . ' wincmd w'
|
||||
let l:target = s:displayed[l:llindex][0]
|
||||
call s:close()
|
||||
call s:split_buffer(l:target,a:mode)
|
||||
else
|
||||
call s:close()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:goto_buffer(bufferno)
|
||||
if(exists("s:buftotabwindow[a:bufferno]"))
|
||||
let l:tabno = s:buftotabwindow[a:bufferno][0]
|
||||
let l:winno = s:buftotabwindow[a:bufferno][1]
|
||||
exe "tabn" .l:tabno
|
||||
exe l:winno. ' wincmd w'
|
||||
endif
|
||||
endfunction
|
||||
function! s:removedifforsource()
|
||||
if(exists("b:buffet_sourcewindowfordiff"))
|
||||
call setwinvar(b:buffet_sourcewindowfordiff,"&diff",0)
|
||||
call setwinvar(b:buffet_sourcewindowfordiff,"&scrollbind",0)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:diff_split_buffer(bufferno,mode)
|
||||
if(a:mode == 'v')
|
||||
exe 'belowright vert '.a:bufferno. ' sbuf'
|
||||
elseif(a:mode == 'h')
|
||||
exe 'belowright ' .a:bufferno. ' sbuf'
|
||||
endif
|
||||
if(exists("s:buflinenos[a:bufferno]"))
|
||||
exe "normal "+s:buflinenos[a:bufferno] + "gg"
|
||||
endif
|
||||
call setwinvar(s:sourcewindow,"&diff",1)
|
||||
call setwinvar(s:sourcewindow,"&scrollbind",1)
|
||||
let b:buffet_sourcewindowfordiff = s:sourcewindow
|
||||
augroup Tlistaco2
|
||||
autocmd!
|
||||
au BufWinLeave <buffer> call <sid>removedifforsource()
|
||||
augroup END
|
||||
|
||||
setlocal diff
|
||||
setlocal scrollbind
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:split_buffer(bufferno,mode)
|
||||
if(a:mode == 'v')
|
||||
exe 'belowright vert '.a:bufferno. ' sbuf'
|
||||
elseif(a:mode == 'h')
|
||||
exe 'belowright ' .a:bufferno. ' sbuf'
|
||||
endif
|
||||
if(exists("s:buflinenos[a:bufferno]"))
|
||||
exe "normal "+s:buflinenos[a:bufferno] + "gg"
|
||||
endif
|
||||
set nodiff
|
||||
set noscrollbind
|
||||
endfunction
|
||||
|
||||
function! s:switch_buffer(bufferno)
|
||||
exe a:bufferno. ' buf!'
|
||||
set nodiff
|
||||
set noscrollbind
|
||||
if(exists("s:buflinenos[a:bufferno]"))
|
||||
exe "normal "+s:buflinenos[a:bufferno] + "gg"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:updaterecent()
|
||||
let l:bufname = bufname("%")
|
||||
let l:j = bufnr('%')
|
||||
if(strlen(l:bufname) > 0 && getbufvar(l:j,'&modifiable') )
|
||||
call filter(s:bufrecent, 'v:val !='. l:j)
|
||||
call insert(s:bufrecent,l:j.'')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:savelineno()
|
||||
let s:buflinenos[bufnr('%')] = line('.')
|
||||
endfunction
|
||||
|
||||
let s:bufrecent = []
|
||||
let s:buflinenos = {}
|
||||
let s:bufferlistlite = {}
|
||||
let s:bufliststatus = 0
|
||||
let s:keybuf = ''
|
||||
let s:lineonclose = 3
|
||||
let s:currentposition = ''
|
||||
let s:firstrun = 1
|
||||
let s:detail = 0
|
||||
augroup Tlistacom
|
||||
autocmd!
|
||||
au BufEnter * call <sid>updaterecent()
|
||||
au BufLeave * call <sid>savelineno()
|
||||
augroup END
|
||||
|
||||
command! Bufferlist :call <sid>toggletop()
|
||||
command! Bufferlistsw :call <sid>togglesw()
|
||||
|
@ -1,28 +0,0 @@
|
||||
" Avoid installing twice or when in unsupported Vim version.
|
||||
if exists('g:loaded_file_line') || (v:version < 700)
|
||||
finish
|
||||
endif
|
||||
let g:loaded_file_line = 1
|
||||
|
||||
function! s:gotoline()
|
||||
let file = bufname("%")
|
||||
" Accept file:line:column: or file:line:column and file:line also
|
||||
let names = matchlist( file, '\(.\{-1,}\):\(\d\+\)\(:\(\d*\):\?\)\?$')
|
||||
|
||||
if len(names) != 0 && filereadable(names[1])
|
||||
let l:bufn = bufnr("%")
|
||||
exec "keepalt edit " . names[1]
|
||||
exec ":" . names[2]
|
||||
exec ":bwipeout " l:bufn
|
||||
if foldlevel(names[2]) > 0
|
||||
exec ":foldopen!"
|
||||
endif
|
||||
|
||||
if (names[4] != '')
|
||||
exec "normal! " . names[4] . '|'
|
||||
endif
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
autocmd! BufNewFile *:* nested call s:gotoline()
|
File diff suppressed because it is too large
Load Diff
@ -1,142 +0,0 @@
|
||||
" tComment.vim -- An easily extensible & universal comment plugin
|
||||
" @Author: Tom Link (micathom AT gmail com)
|
||||
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
||||
" @Created: 27-Dez-2004.
|
||||
" @Last Change: 2011-05-26.
|
||||
" @Revision: 720
|
||||
" GetLatestVimScripts: 1173 1 tcomment.vim
|
||||
|
||||
if &cp || exists('loaded_tcomment')
|
||||
finish
|
||||
endif
|
||||
let loaded_tcomment = 205
|
||||
|
||||
if !exists("g:tcommentMapLeader1")
|
||||
" g:tcommentMapLeader1 should be a shortcut that can be used with
|
||||
" map, imap, vmap.
|
||||
let g:tcommentMapLeader1 = '<c-_>'
|
||||
endif
|
||||
if !exists("g:tcommentMapLeader2")
|
||||
" g:tcommentMapLeader2 should be a shortcut that can be used with
|
||||
" map, xmap.
|
||||
let g:tcommentMapLeader2 = '<Leader>_'
|
||||
endif
|
||||
if !exists("g:tcommentMapLeaderOp1")
|
||||
let g:tcommentMapLeaderOp1 = 'gc'
|
||||
endif
|
||||
if !exists("g:tcommentMapLeaderOp2")
|
||||
let g:tcommentMapLeaderOp2 = 'gC'
|
||||
endif
|
||||
|
||||
|
||||
" :display: :[range]TComment[!] ?ARGS...
|
||||
" If there is a visual selection that begins and ends in the same line,
|
||||
" then |:TCommentInline| is used instead.
|
||||
" The optional range defaults to the current line. With a bang '!',
|
||||
" always comment the line.
|
||||
"
|
||||
" ARGS... are either (see also |tcomment#Comment()|):
|
||||
" 1. a list of key=value pairs
|
||||
" 2. 1-2 values for: ?commentBegin, ?commentEnd
|
||||
command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TComment
|
||||
\ keepjumps call tcomment#Comment(<line1>, <line2>, 'G', "<bang>", <f-args>)
|
||||
|
||||
" :display: :[range]TCommentAs[!] commenttype ?ARGS...
|
||||
" TCommentAs requires g:tcomment_{filetype} to be defined.
|
||||
" With a bang '!', always comment the line.
|
||||
"
|
||||
" ARGS... are either (see also |tcomment#Comment()|):
|
||||
" 1. a list of key=value pairs
|
||||
" 2. 1-2 values for: ?commentBegin, ?commentEnd
|
||||
command! -bang -complete=customlist,tcomment#Complete -range -nargs=+ TCommentAs
|
||||
\ call tcomment#CommentAs(<line1>, <line2>, "<bang>", <f-args>)
|
||||
|
||||
" :display: :[range]TCommentRight[!] ?ARGS...
|
||||
" Comment the text to the right of the cursor. If a visual selection was
|
||||
" made (be it block-wise or not), all lines are commented out at from
|
||||
" the current cursor position downwards.
|
||||
" With a bang '!', always comment the line.
|
||||
"
|
||||
" ARGS... are either (see also |tcomment#Comment()|):
|
||||
" 1. a list of key=value pairs
|
||||
" 2. 1-2 values for: ?commentBegin, ?commentEnd
|
||||
command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TCommentRight
|
||||
\ keepjumps call tcomment#Comment(<line1>, <line2>, 'R', "<bang>", <f-args>)
|
||||
|
||||
" :display: :[range]TCommentBlock[!] ?ARGS...
|
||||
" Comment as "block", e.g. use the {&ft}_block comment style. The
|
||||
" commented text isn't indented or reformated.
|
||||
" With a bang '!', always comment the line.
|
||||
"
|
||||
" ARGS... are either (see also |tcomment#Comment()|):
|
||||
" 1. a list of key=value pairs
|
||||
" 2. 1-2 values for: ?commentBegin, ?commentEnd
|
||||
command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TCommentBlock
|
||||
\ keepjumps call tcomment#Comment(<line1>, <line2>, 'B', "<bang>", <f-args>)
|
||||
|
||||
" :display: :[range]TCommentInline[!] ?ARGS...
|
||||
" Use the {&ft}_inline comment style.
|
||||
" With a bang '!', always comment the line.
|
||||
"
|
||||
" ARGS... are either (see also |tcomment#Comment()|):
|
||||
" 1. a list of key=value pairs
|
||||
" 2. 1-2 values for: ?commentBegin, ?commentEnd
|
||||
command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TCommentInline
|
||||
\ keepjumps call tcomment#Comment(<line1>, <line2>, 'I', "<bang>", <f-args>)
|
||||
|
||||
" :display: :[range]TCommentMaybeInline[!] ?ARGS...
|
||||
" With a bang '!', always comment the line.
|
||||
"
|
||||
" ARGS... are either (see also |tcomment#Comment()|):
|
||||
" 1. a list of key=value pairs
|
||||
" 2. 1-2 values for: ?commentBegin, ?commentEnd
|
||||
command! -bang -range -nargs=* -complete=customlist,tcomment#CompleteArgs TCommentMaybeInline
|
||||
\ keepjumps call tcomment#Comment(<line1>, <line2>, 'i', "<bang>", <f-args>)
|
||||
|
||||
|
||||
|
||||
if (g:tcommentMapLeader1 != '')
|
||||
exec 'noremap <silent> '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' :TComment<cr>'
|
||||
exec 'vnoremap <silent> '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' :TCommentMaybeInline<cr>'
|
||||
exec 'inoremap <silent> '. g:tcommentMapLeader1 . g:tcommentMapLeader1 .' <c-o>:TComment<cr>'
|
||||
exec 'noremap <silent> '. g:tcommentMapLeader1 .'p m`vip:TComment<cr>``'
|
||||
exec 'inoremap <silent> '. g:tcommentMapLeader1 .'p <c-o>:norm! m`vip<cr>:TComment<cr><c-o>``'
|
||||
exec 'noremap '. g:tcommentMapLeader1 .'<space> :TComment '
|
||||
exec 'inoremap '. g:tcommentMapLeader1 .'<space> <c-o>:TComment '
|
||||
exec 'inoremap <silent> '. g:tcommentMapLeader1 .'r <c-o>:TCommentRight<cr>'
|
||||
exec 'noremap <silent> '. g:tcommentMapLeader1 .'r :TCommentRight<cr>'
|
||||
exec 'vnoremap <silent> '. g:tcommentMapLeader1 .'i :TCommentInline<cr>'
|
||||
exec 'vnoremap <silent> '. g:tcommentMapLeader1 .'r :TCommentRight<cr>'
|
||||
exec 'noremap '. g:tcommentMapLeader1 .'b :TCommentBlock<cr>'
|
||||
exec 'inoremap '. g:tcommentMapLeader1 .'b <c-o>:TCommentBlock<cr>'
|
||||
exec 'noremap '. g:tcommentMapLeader1 .'a :TCommentAs '
|
||||
exec 'inoremap '. g:tcommentMapLeader1 .'a <c-o>:TCommentAs '
|
||||
exec 'noremap '. g:tcommentMapLeader1 .'n :TCommentAs <c-r>=&ft<cr> '
|
||||
exec 'inoremap '. g:tcommentMapLeader1 .'n <c-o>:TCommentAs <c-r>=&ft<cr> '
|
||||
exec 'noremap '. g:tcommentMapLeader1 .'s :TCommentAs <c-r>=&ft<cr>_'
|
||||
exec 'inoremap '. g:tcommentMapLeader1 .'s <c-o>:TCommentAs <c-r>=&ft<cr>_'
|
||||
endif
|
||||
if (g:tcommentMapLeader2 != '')
|
||||
exec 'noremap <silent> '. g:tcommentMapLeader2 .'_ :TComment<cr>'
|
||||
exec 'xnoremap <silent> '. g:tcommentMapLeader2 .'_ :TCommentMaybeInline<cr>'
|
||||
exec 'noremap <silent> '. g:tcommentMapLeader2 .'p vip:TComment<cr>'
|
||||
exec 'noremap '. g:tcommentMapLeader2 .'<space> :TComment '
|
||||
exec 'xnoremap <silent> '. g:tcommentMapLeader2 .'i :TCommentInline<cr>'
|
||||
exec 'noremap <silent> '. g:tcommentMapLeader2 .'r :TCommentRight<cr>'
|
||||
exec 'xnoremap <silent> '. g:tcommentMapLeader2 .'r :TCommentRight<cr>'
|
||||
exec 'noremap '. g:tcommentMapLeader2 .'b :TCommentBlock<cr>'
|
||||
exec 'noremap '. g:tcommentMapLeader2 .'a :TCommentAs '
|
||||
exec 'noremap '. g:tcommentMapLeader2 .'n :TCommentAs <c-r>=&ft<cr> '
|
||||
exec 'noremap '. g:tcommentMapLeader2 .'s :TCommentAs <c-r>=&ft<cr>_'
|
||||
endif
|
||||
if (g:tcommentMapLeaderOp1 != '')
|
||||
exec 'nnoremap <silent> '. g:tcommentMapLeaderOp1 .' :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#Operator<cr>g@'
|
||||
exec 'nnoremap <silent> '. g:tcommentMapLeaderOp1 .'c :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLine<cr>g@$'
|
||||
exec 'xnoremap <silent> '. g:tcommentMapLeaderOp1 .' :TCommentMaybeInline<cr>'
|
||||
endif
|
||||
if (g:tcommentMapLeaderOp2 != '')
|
||||
exec 'nnoremap <silent> '. g:tcommentMapLeaderOp2 .' :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorAnyway<cr>g@'
|
||||
exec 'nnoremap <silent> '. g:tcommentMapLeaderOp2 .'c :let w:tcommentPos = getpos(".") \| set opfunc=tcomment#OperatorLineAnyway<cr>g@$'
|
||||
exec 'xnoremap <silent> '. g:tcommentMapLeaderOp2 .' :TCommentMaybeInline<cr>'
|
||||
endif
|
||||
|
@ -1,88 +0,0 @@
|
||||
let s:tree_up_dir_line = '.. (up a dir)'
|
||||
"NERDTreeFlags are syntax items that should be invisible, but give clues as to
|
||||
"how things should be highlighted
|
||||
syn match NERDTreeFlag #\~#
|
||||
syn match NERDTreeFlag #\[RO\]#
|
||||
|
||||
"highlighting for the .. (up dir) line at the top of the tree
|
||||
execute "syn match NERDTreeUp #\\V". s:tree_up_dir_line ."#"
|
||||
|
||||
"highlighting for the ~/+ symbols for the directory nodes
|
||||
syn match NERDTreeClosable #\~\<#
|
||||
syn match NERDTreeClosable #\~\.#
|
||||
syn match NERDTreeOpenable #+\<#
|
||||
syn match NERDTreeOpenable #+\.#he=e-1
|
||||
|
||||
"highlighting for the tree structural parts
|
||||
syn match NERDTreePart #|#
|
||||
syn match NERDTreePart #`#
|
||||
syn match NERDTreePartFile #[|`]-#hs=s+1 contains=NERDTreePart
|
||||
|
||||
"quickhelp syntax elements
|
||||
syn match NERDTreeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1
|
||||
syn match NERDTreeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1
|
||||
syn match NERDTreeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=NERDTreeFlag
|
||||
syn match NERDTreeToggleOn #".*(on)#hs=e-2,he=e-1 contains=NERDTreeHelpKey
|
||||
syn match NERDTreeToggleOff #".*(off)#hs=e-3,he=e-1 contains=NERDTreeHelpKey
|
||||
syn match NERDTreeHelpCommand #" :.\{-}\>#hs=s+3
|
||||
syn match NERDTreeHelp #^".*# contains=NERDTreeHelpKey,NERDTreeHelpTitle,NERDTreeFlag,NERDTreeToggleOff,NERDTreeToggleOn,NERDTreeHelpCommand
|
||||
|
||||
"highlighting for readonly files
|
||||
syn match NERDTreeRO #.*\[RO\]#hs=s+2 contains=NERDTreeFlag,NERDTreeBookmark,NERDTreePart,NERDTreePartFile
|
||||
|
||||
"highlighting for sym links
|
||||
syn match NERDTreeLink #[^-| `].* -> # contains=NERDTreeBookmark,NERDTreeOpenable,NERDTreeClosable,NERDTreeDirSlash
|
||||
|
||||
"highlighing for directory nodes and file nodes
|
||||
syn match NERDTreeDirSlash #/#
|
||||
syn match NERDTreeDir #[^-| `].*/# contains=NERDTreeLink,NERDTreeDirSlash,NERDTreeOpenable,NERDTreeClosable
|
||||
syn match NERDTreeExecFile #[|` ].*\*\($\| \)# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark
|
||||
syn match NERDTreeFile #|-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
|
||||
syn match NERDTreeFile #`-.*# contains=NERDTreeLink,NERDTreePart,NERDTreeRO,NERDTreePartFile,NERDTreeBookmark,NERDTreeExecFile
|
||||
syn match NERDTreeCWD #^[</].*$#
|
||||
|
||||
"highlighting for bookmarks
|
||||
syn match NERDTreeBookmark # {.*}#hs=s+1
|
||||
|
||||
"highlighting for the bookmarks table
|
||||
syn match NERDTreeBookmarksLeader #^>#
|
||||
syn match NERDTreeBookmarksHeader #^>-\+Bookmarks-\+$# contains=NERDTreeBookmarksLeader
|
||||
syn match NERDTreeBookmarkName #^>.\{-} #he=e-1 contains=NERDTreeBookmarksLeader
|
||||
syn match NERDTreeBookmark #^>.*$# contains=NERDTreeBookmarksLeader,NERDTreeBookmarkName,NERDTreeBookmarksHeader
|
||||
|
||||
if exists("g:NERDChristmasTree") && g:NERDChristmasTree
|
||||
hi def link NERDTreePart Special
|
||||
hi def link NERDTreePartFile Type
|
||||
hi def link NERDTreeFile Normal
|
||||
hi def link NERDTreeExecFile Title
|
||||
hi def link NERDTreeDirSlash Identifier
|
||||
hi def link NERDTreeClosable Type
|
||||
else
|
||||
hi def link NERDTreePart Normal
|
||||
hi def link NERDTreePartFile Normal
|
||||
hi def link NERDTreeFile Normal
|
||||
hi def link NERDTreeClosable Title
|
||||
endif
|
||||
|
||||
hi def link NERDTreeBookmarksHeader statement
|
||||
hi def link NERDTreeBookmarksLeader ignore
|
||||
hi def link NERDTreeBookmarkName Identifier
|
||||
hi def link NERDTreeBookmark normal
|
||||
|
||||
hi def link NERDTreeHelp String
|
||||
hi def link NERDTreeHelpKey Identifier
|
||||
hi def link NERDTreeHelpCommand Identifier
|
||||
hi def link NERDTreeHelpTitle Macro
|
||||
hi def link NERDTreeToggleOn Question
|
||||
hi def link NERDTreeToggleOff WarningMsg
|
||||
|
||||
hi def link NERDTreeDir Directory
|
||||
hi def link NERDTreeUp Directory
|
||||
hi def link NERDTreeCWD Statement
|
||||
hi def link NERDTreeLink Macro
|
||||
hi def link NERDTreeOpenable Title
|
||||
hi def link NERDTreeFlag ignore
|
||||
hi def link NERDTreeRO WarningMsg
|
||||
hi def link NERDTreeBookmark Statement
|
||||
|
||||
hi def link NERDTreeCurrentNode Search
|
125
vim/dot_vimrc
125
vim/dot_vimrc
@ -1,6 +1,47 @@
|
||||
" Vundle
|
||||
filetype off " required!
|
||||
|
||||
set rtp+=~/.vim/bundle/vundle/
|
||||
call vundle#rc()
|
||||
|
||||
" let Vundle manage Vundle
|
||||
" required!
|
||||
Bundle 'gmarik/vundle'
|
||||
|
||||
" Rest of my bundles
|
||||
|
||||
" File Nav
|
||||
Bundle 'kien/ctrlp.vim'
|
||||
Bundle 'scrooloose/nerdtree'
|
||||
Bundle 'a.vim'
|
||||
Bundle 'file-line'
|
||||
" Needs Vim compiled with Ruby
|
||||
Bundle 'wincent/Command-T'
|
||||
Bundle 'tpope/vim-fugitive'
|
||||
|
||||
" Buffer Nav
|
||||
Bundle 'kien/tabman.vim'
|
||||
Bundle 'sandeepcr529/Buffet.vim'
|
||||
" Needs Vim compiled with Ruby
|
||||
Bundle 'mutewinter/LustyJuggler'
|
||||
|
||||
" Nav in file
|
||||
Bundle 'taglist.vim'
|
||||
|
||||
" Text Manipulation
|
||||
Bundle 'tomtom/tcomment_vim'
|
||||
|
||||
" GUI
|
||||
Bundle 'vividchalk.vim'
|
||||
Bundle 'gregsexton/MatchTag'
|
||||
|
||||
"Allow arrow keys
|
||||
set nocompatible
|
||||
|
||||
"Enable mouse input
|
||||
set mousehide
|
||||
set mouse=a
|
||||
|
||||
"tab functionality
|
||||
"tabs inserted as 4 spaces
|
||||
"backspace deletes all spaces
|
||||
@ -10,14 +51,17 @@ set tabstop=4
|
||||
set shiftwidth=4
|
||||
set softtabstop=4
|
||||
set autoindent
|
||||
filetype indent on
|
||||
filetype plugin indent on
|
||||
|
||||
set virtualedit=onemore " allow for cursor beyond last character
|
||||
set scrolljump=5 " lines to scroll when cursor leaves screen
|
||||
set scrolloff=3 " minimum lines to keep above and below cursor
|
||||
|
||||
"Enable search highlighting
|
||||
set hls
|
||||
"Set backup dirs
|
||||
set backup
|
||||
set backupdir=~/.vim/backup
|
||||
set directory=~/.vim/tmp
|
||||
|
||||
|
||||
"set theme
|
||||
:colorscheme vividchalk
|
||||
@ -61,6 +105,14 @@ map <S-u> <C-r>
|
||||
" Buffet shortcut
|
||||
nnoremap <silent> <F2> :Bufferlist<CR>
|
||||
|
||||
"LustyJugler settings
|
||||
let g:LustyJugglerShowKeys=1 "Show numbers for Lusty Buffers
|
||||
let g:LustyJugglerSuppressRubyWarning=1
|
||||
|
||||
"NERDTree
|
||||
nnoremap <leader>nn :NERDTreeToggle<CR>
|
||||
nnoremap <leader>nf :NERDTreeFind<CR>
|
||||
|
||||
"CTags List
|
||||
nnoremap <silent> <F8> :TlistToggle<CR>
|
||||
let Tlist_Exit_OnlyWindow=1
|
||||
@ -78,10 +130,13 @@ inoremap <Nul> <C-n>
|
||||
|
||||
" Stupid shift key fixes
|
||||
"cmap W w
|
||||
cmap WQ wq
|
||||
cmap Wq wq
|
||||
"cmap Q q
|
||||
cmap WQ<CR> wq<CR>
|
||||
cmap Wq<CR> wq<CR>
|
||||
cmap W<CR> w<CR>
|
||||
cmap Q<CR> q<CR>
|
||||
|
||||
"Enable search highlighting
|
||||
set hls
|
||||
"clearing highlighted search
|
||||
nmap <silent> <leader>/ :nohlsearch<CR>
|
||||
|
||||
@ -89,3 +144,61 @@ nmap <silent> <leader>/ :nohlsearch<CR>
|
||||
cmap cwd lcd %:p:h
|
||||
cmap cd. lcd %:p:h
|
||||
|
||||
" ---------------
|
||||
" Command T and ctrlp.vim
|
||||
" Snagged from mutewinter @ https://github.com/mutewinter/dot_vim
|
||||
" ---------------
|
||||
" Ensure Ctrl-P isn't bound by default
|
||||
let g:ctrlp_map = ''
|
||||
|
||||
" Ensure max height isn't too large. (for performance)
|
||||
let g:ctrlp_max_height = 10
|
||||
let g:CommandTMaxHeight = 10
|
||||
|
||||
" Set the default escape keybinding to, you guessed it, escape.
|
||||
let g:CommandTCancelMap = '<esc>'
|
||||
|
||||
" Dynamically use Command T or ctrlp.vim based on availability of Ruby.
|
||||
" We do this because Command T is much faster than ctrlp.vim.
|
||||
if has('ruby')
|
||||
" --------
|
||||
" Use Command T since we've got Ruby
|
||||
" --------
|
||||
|
||||
" Conditional Mappings
|
||||
if has('unix')
|
||||
nnoremap <silent><C-t> :CommandT<CR>
|
||||
else
|
||||
nnoremap <silent><M-t> :CommandT<CR>
|
||||
endif
|
||||
|
||||
" Leader Commands
|
||||
nnoremap <leader>t :CommandT<CR>
|
||||
else
|
||||
" --------
|
||||
" Use ctrlp.vim since we don't have Ruby
|
||||
" --------
|
||||
|
||||
" Conditional Mappings
|
||||
if has('unix')
|
||||
let g:ctrlp_map = '<C-t>'
|
||||
else
|
||||
let g:ctrlp_map = '<M-t>'
|
||||
endif
|
||||
|
||||
" Leader Commands
|
||||
nnoremap <leader>t :CtrlPRoot<CR>
|
||||
nnoremap <leader>b :CtrlPBuffer<CR>
|
||||
endif
|
||||
|
||||
" Always use CtrlP for most recently used files and relative dierctory.
|
||||
if has('unix')
|
||||
nnoremap <silent><C-u> :CtrlPCurFile<CR>
|
||||
else
|
||||
nnoremap <silent><M-u> :CtrlPCurFile<CR>
|
||||
endif
|
||||
|
||||
" Also map leader commands
|
||||
nnoremap <leader>u :CtrlPCurFile<CR>
|
||||
nnoremap <leader>m :CtrlPMRUFiles<CR>
|
||||
nnoremap <leader>b :CtrlPBuffer<CR>
|
||||
|
Loading…
Reference in New Issue
Block a user