2004-06-13 20:20:40 +00:00
" Vim support file to define the default menus
" You can also use this as a start for your own set of menus.
"
2023-08-13 10:33:05 +02:00
" Maintainer: The Vim Project <https://github.com/vim/vim>
" Last Change: 2023 Aug 10
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
2004-06-13 20:20:40 +00:00
" Note that ":an" (short for ":anoremenu") is often used to make a menu work
" in all modes and avoid side effects from mappings defined by the user.
" Make sure the '<' and 'C' flags are not included in 'cpoptions', otherwise
" <CR> would not be recognized. See ":help 'cpoptions'".
let s :cpo_save = &cpo
set cpo &vim
" Avoid installing the menus twice
if ! exists ( "did_install_default_menus" )
let did_install_default_menus = 1
if exists ( "v:lang" ) | | &langmenu ! = ""
" Try to find a menu translation file for the current language.
if &langmenu ! = ""
if &langmenu = ~ "none"
let s :lang = ""
else
let s :lang = &langmenu
endif
else
let s :lang = v :lang
endif
" A language name must be at least two characters, don't accept "C"
2019-09-27 19:34:08 +02:00
" Also skip "en_US" to avoid picking up "en_gb" translations.
if strlen ( s :lang ) > 1 && s :lang ! ~ ? '^en_us'
2004-06-13 20:20:40 +00:00
" When the language does not include the charset add 'encoding'
if s :lang = ~ '^\a\a$\|^\a\a_\a\a$'
2022-02-04 19:48:06 +00:00
let s :lang = s :lang .. '.' .. &enc
2004-06-13 20:20:40 +00:00
endif
" We always use a lowercase name.
" Change "iso-8859" to "iso_8859" and "iso8859" to "iso_8859", some
" systems appear to use this.
" Change spaces to underscores.
let s :lang = substitute ( tolower ( s :lang ) , '\.iso-' , ".iso_" , "" )
let s :lang = substitute ( s :lang , '\.iso8859' , ".iso_8859" , "" )
let s :lang = substitute ( s :lang , " " , "_" , "g" )
" Remove "@euro", otherwise "LC_ALL=de_DE@euro gvim" will show English menus
let s :lang = substitute ( s :lang , "@euro" , "" , "" )
" Change "iso_8859-1" and "iso_8859-15" to "latin1", we always use the
" same menu file for them.
let s :lang = substitute ( s :lang , 'iso_8859-15\=$' , "latin1" , "" )
menutrans clear
2022-02-04 19:48:06 +00:00
exe "runtime! lang/menu_" .. s :lang .. ".vim"
2004-06-13 20:20:40 +00:00
if ! exists ( "did_menu_trans" )
" There is no exact match, try matching with a wildcard added
" (e.g. find menu_de_de.iso_8859-1.vim if s:lang == de_DE).
let s :lang = substitute ( s :lang , '\.[^.]*' , "" , "" )
2022-02-04 19:48:06 +00:00
exe "runtime! lang/menu_" .. s :lang .. "[^a-z]*vim"
2004-06-13 20:20:40 +00:00
2018-07-23 05:10:14 +02:00
if ! exists ( "did_menu_trans" ) && s :lang = ~ '_'
" If the language includes a region try matching without that region.
" (e.g. find menu_de.vim if s:lang == de_DE).
let langonly = substitute ( s :lang , '_.*' , "" , "" )
2022-02-04 19:48:06 +00:00
exe "runtime! lang/menu_" .. langonly .. "[^a-z]*vim"
2018-07-23 05:10:14 +02:00
endif
2005-03-15 22:43:58 +00:00
if ! exists ( "did_menu_trans" ) && strlen ( $LANG ) > 1 && s :lang ! ~ '^en_us'
2004-06-13 20:20:40 +00:00
" On windows locale names are complicated, try using $LANG, it might
2005-03-15 22:43:58 +00:00
" have been set by set_init_1(). But don't do this for "en" or "en_us".
2005-01-31 19:19:04 +00:00
" But don't match "slovak" when $LANG is "sl".
2022-02-04 19:48:06 +00:00
exe "runtime! lang/menu_" .. tolower ( $LANG ) .. "[^a-z]*vim"
2004-06-13 20:20:40 +00:00
endif
endif
endif
endif
" Help menu
an 9999 .10 &Help .&Overview < Tab > < F1 > :help < CR >
an 9999 .20 &Help .&User \ Manual :help usr_toc < CR >
2017-03-05 17:04:09 +01:00
an 9999 .30 &Help .&How - To \ Links :help how - to < CR >
2004-06-13 20:20:40 +00:00
an < silent > 9999 .40 &Help .&Find \.\.\. :call < SID > Helpfind ( ) < CR >
an 9999 .45 &Help .- sep1 - < Nop >
an 9999 .50 &Help .&Credits :help credits < CR >
an 9999 .60 &Help .Co &pying :help copying < CR >
an 9999 .70 &Help .&Sponsor /Register :help sponsor < CR >
an 9999 .70 &Help .O &rphans :help kcc < CR >
an 9999 .75 &Help .- sep2 - < Nop >
an 9999 .80 &Help .&Version :version < CR >
an 9999 .90 &Help .&About :intro < CR >
2020-09-28 21:41:49 +02:00
if exists ( ':tlmenu' )
tlnoremenu 9999 .10 &Help .&Overview < Tab > < F1 > < C - W > :help < CR >
tlnoremenu 9999 .20 &Help .&User \ Manual < C - W > :help usr_toc < CR >
tlnoremenu 9999 .30 &Help .&How - To \ Links < C - W > :help how - to < CR >
tlnoremenu < silent > 9999 .40 &Help .&Find \.\.\. < C - W > :call < SID > Helpfind ( ) < CR >
tlnoremenu 9999 .45 &Help .- sep1 - < Nop >
tlnoremenu 9999 .50 &Help .&Credits < C - W > :help credits < CR >
tlnoremenu 9999 .60 &Help .Co &pying < C - W > :help copying < CR >
tlnoremenu 9999 .70 &Help .&Sponsor /Register < C - W > :help sponsor < CR >
tlnoremenu 9999 .70 &Help .O &rphans < C - W > :help kcc < CR >
tlnoremenu 9999 .75 &Help .- sep2 - < Nop >
tlnoremenu 9999 .80 &Help .&Version < C - W > :version < CR >
tlnoremenu 9999 .90 &Help .&About < C - W > :intro < CR >
endif
2022-02-04 19:48:06 +00:00
def s :Helpfind ( )
2004-06-13 20:20:40 +00:00
if ! exists ( "g:menutrans_help_dialog" )
2022-02-04 19:48:06 +00:00
g :menutrans_help_dialog = "Enter a command or word to find help on:\n\nPrepend i_ for Input mode commands (e.g.: i_CTRL-X)\nPrepend c_ for command-line editing commands (e.g.: c_<Del>)\nPrepend ' for an option name (e.g.: 'shiftwidth')"
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
var h = inputdialog ( g :menutrans_help_dialog )
2004-06-13 20:20:40 +00:00
if h ! = ""
2022-02-04 19:48:06 +00:00
v :errmsg = ""
silent ! exe "help " .. h
2004-06-13 20:20:40 +00:00
if v :errmsg ! = ""
echo v :errmsg
endif
endif
2022-02-04 19:48:06 +00:00
enddef
2004-06-13 20:20:40 +00:00
" File menu
an 10 .310 &File .&Open \.\.\.< Tab > :e :browse confirm e < CR >
an 10 .320 &File .Sp &lit - Open \.\.\.< Tab > :sp :browse sp < CR >
2023-08-23 17:07:55 +01:00
an 10 .320 &File .Open \ &Tab \.\.\.< Tab > :tabnew :browse tabnew < CR >
2004-06-13 20:20:40 +00:00
an 10 .325 &File .&New < Tab > :enew :confirm enew < CR >
an < silent > 10 .330 &File .&Close < Tab > :close
2011-03-22 17:40:10 +01:00
\ :if winheight ( 2 ) < 0 && tabpagewinnr ( 2 ) = = 0 < Bar >
2004-06-13 20:20:40 +00:00
\ confirm enew < Bar >
\ else < Bar >
\ confirm close < Bar >
\ endif < CR >
2022-10-09 18:53:32 +01:00
tln < silent > 10 .330 &File .&Close < Tab > :close
\ < C - W > :if winheight ( 2 ) < 0 && tabpagewinnr ( 2 ) = = 0 < Bar >
\ confirm enew < Bar >
\ else < Bar >
\ confirm close < Bar >
\ endif < CR >
2004-06-13 20:20:40 +00:00
an 10 .335 &File .- SEP1 - < Nop >
an < silent > 10 .340 &File .&Save < Tab > :w :if expand ( "%" ) = = "" < Bar > browse confirm w < Bar > else < Bar > confirm w < Bar > endif < CR >
an 10 .350 &File .Save \ &As \.\.\.< Tab > :sav :browse confirm saveas < CR >
if has ( "diff" )
an 10 .400 &File .- SEP2 - < Nop >
2017-03-05 17:04:09 +01:00
an 10 .410 &File .Split \ &Diff \ With \.\.\. :browse vert diffsplit < CR >
2004-06-13 20:20:40 +00:00
an 10 .420 &File .Split \ Patched \ &By \.\.\. :browse vert diffpatch < CR >
endif
if has ( "printer" )
an 10 .500 &File .- SEP3 - < Nop >
an 10 .510 &File .&Print :hardcopy < CR >
vunmenu &File .&Print
vnoremenu &File .&Print :hardcopy < CR >
elseif has ( "unix" )
an 10 .500 &File .- SEP3 - < Nop >
an 10 .510 &File .&Print :w ! lpr < CR >
vunmenu &File .&Print
vnoremenu &File .&Print :w ! lpr < CR >
endif
an 10 .600 &File .- SEP4 - < Nop >
an 10 .610 &File .Sa &ve - Exit < Tab > :wqa :confirm wqa < CR >
an 10 .620 &File .E &xit < Tab > :qa :confirm qa < CR >
2022-02-04 19:48:06 +00:00
def s :SelectAll ( )
exe "norm! gg" .. ( &slm = = "" ? "VG" : "gH\<C-O>G" )
enddef
2004-06-13 20:20:40 +00:00
" Edit menu
an 20 .310 &Edit .&Undo < Tab > u u
an 20 .320 &Edit .&Redo < Tab > ^R < C - R >
an 20 .330 &Edit .Rep &eat < Tab > \. .
an 20 .335 &Edit .- SEP1 - < Nop >
vnoremenu 20 .340 &Edit .Cu &t < Tab > "+x " + x
vnoremenu 20 .350 &Edit .&Copy < Tab > "+y " + y
cnoremenu 20 .350 &Edit .&Copy < Tab > "+ y < C - Y >
2019-11-10 22:09:11 +01:00
if exists ( ':tlmenu' )
tlnoremenu 20 .350 &Edit .&Copy < Tab > "+ y < C - W > :< C - Y > < CR >
endif
2004-06-13 20:20:40 +00:00
nnoremenu 20 .360 &Edit .&Paste < Tab > "+gP " + gP
cnoremenu &Edit .&Paste < Tab > "+ gP < C - R > +
2018-10-19 22:36:53 +02:00
if exists ( ':tlmenu' )
tlnoremenu &Edit .&Paste < Tab > "+gP <C-W>" +
endif
2022-02-04 19:48:06 +00:00
exe 'vnoremenu <script> &Edit.&Paste<Tab>"+gP ' .. paste #paste_cmd ['v' ]
exe 'inoremenu <script> &Edit.&Paste<Tab>"+gP ' .. paste #paste_cmd ['i' ]
2004-06-13 20:20:40 +00:00
nnoremenu 20 .370 &Edit .Put \ &Before < Tab > [p [p
inoremenu &Edit .Put \ &Before < Tab > [p < C - O > [p
nnoremenu 20 .380 &Edit .Put \ &After < Tab > ]p ]p
inoremenu &Edit .Put \ &After < Tab > ]p < C - O > ]p
2017-11-09 19:45:48 +01:00
if has ( "win32" )
2004-06-13 20:20:40 +00:00
vnoremenu 20 .390 &Edit .&Delete < Tab > x x
endif
noremenu < script > < silent > 20 .400 &Edit .&Select \ All < Tab > ggVG :< C - U > call < SID > SelectAll ( ) < CR >
inoremenu < script > < silent > 20 .400 &Edit .&Select \ All < Tab > ggVG < C - O > :call < SID > SelectAll ( ) < CR >
cnoremenu < script > < silent > 20 .400 &Edit .&Select \ All < Tab > ggVG < C - U > call < SID > SelectAll ( ) < CR >
an 20 .405 &Edit .- SEP2 - < Nop >
2017-11-09 19:45:48 +01:00
if has ( "win32" ) | | has ( "gui_gtk" ) | | has ( "gui_kde" ) | | has ( "gui_motif" )
2004-06-13 20:20:40 +00:00
an 20 .410 &Edit .&Find \.\.\. :promptfind < CR >
vunmenu &Edit .&Find \.\.\.
2006-03-09 22:32:39 +00:00
vnoremenu < silent > &Edit .&Find \.\.\. y :promptfind < C - R > = < SID > FixFText ( ) < CR > < CR >
2004-06-13 20:20:40 +00:00
an 20 .420 &Edit .Find \ and \ Rep &lace \.\.\. :promptrepl < CR >
vunmenu &Edit .Find \ and \ Rep &lace \.\.\.
2006-03-09 22:32:39 +00:00
vnoremenu < silent > &Edit .Find \ and \ Rep &lace \.\.\. y :promptrepl < C - R > = < SID > FixFText ( ) < CR > < CR >
2004-06-13 20:20:40 +00:00
else
an 20 .410 &Edit .&Find < Tab > / /
an 20 .420 &Edit .Find \ and \ Rep &lace < Tab > :%s :%s /
vunmenu &Edit .Find \ and \ Rep &lace < Tab > :%s
vnoremenu &Edit .Find \ and \ Rep &lace < Tab > :s :s /
endif
an 20 .425 &Edit .- SEP3 - < Nop >
an 20 .430 &Edit .Settings \ &Window :options < CR >
2006-04-05 20:41:53 +00:00
an 20 .435 &Edit .Startup \ &Settings :call < SID > EditVimrc ( ) < CR >
2022-02-04 19:48:06 +00:00
def s :EditVimrc ( )
var fname : string
2006-04-05 20:41:53 +00:00
if $MYVIMRC ! = ''
2022-02-04 19:48:06 +00:00
fname = $MYVIMRC
2016-07-17 13:35:14 +02:00
elseif has ( "win32" )
2006-04-05 20:41:53 +00:00
if $HOME ! = ''
2022-02-04 19:48:06 +00:00
fname = $HOME .. "/_vimrc"
2006-04-05 20:41:53 +00:00
else
2022-02-04 19:48:06 +00:00
fname = $VIM .. "/_vimrc"
2006-04-05 20:41:53 +00:00
endif
elseif has ( "amiga" )
2022-02-04 19:48:06 +00:00
fname = "s:.vimrc"
2006-04-05 20:41:53 +00:00
else
2022-02-04 19:48:06 +00:00
fname = $HOME .. "/.vimrc"
2006-04-05 20:41:53 +00:00
endif
2022-02-04 19:48:06 +00:00
fname = fnameescape ( fname )
2006-04-05 20:41:53 +00:00
if &mod
2022-02-04 19:48:06 +00:00
exe "split " .. fname
2006-04-05 20:41:53 +00:00
else
2022-02-04 19:48:06 +00:00
exe "edit " .. fname
2006-04-05 20:41:53 +00:00
endif
2022-02-04 19:48:06 +00:00
enddef
2004-06-13 20:20:40 +00:00
2022-02-04 19:48:06 +00:00
def s :FixFText ( ) : string
# Fix text in nameless register to be used with :promptfind .
2006-03-09 22:32:39 +00:00
return substitute ( @", " [\r \n ]", '\\n' , 'g' )
2022-02-04 19:48:06 +00:00
enddef
2005-08-16 23:01:50 +00:00
2004-06-13 20:20:40 +00:00
" Edit/Global Settings
an 20 .440 .100 &Edit .&Global \ Settings .Toggle \ Pattern \ &Highlight < Tab > :set \ hls ! :set hls ! hls ?< CR >
2017-03-05 17:04:09 +01:00
an 20 .440 .110 &Edit .&Global \ Settings .Toggle \ &Ignoring \ Case < Tab > :set \ ic ! :set ic ! ic ?< CR >
an 20 .440 .110 &Edit .&Global \ Settings .Toggle \ &Showing \ Matched \ Pairs < Tab > :set \ sm ! :set sm ! sm ?< CR >
an 20 .440 .120 &Edit .&Global \ Settings .&Context \ Lines .\ 1 \ :set so = 1 < CR >
an 20 .440 .120 &Edit .&Global \ Settings .&Context \ Lines .\ 2 \ :set so = 2 < CR >
an 20 .440 .120 &Edit .&Global \ Settings .&Context \ Lines .\ 3 \ :set so = 3 < CR >
an 20 .440 .120 &Edit .&Global \ Settings .&Context \ Lines .\ 4 \ :set so = 4 < CR >
an 20 .440 .120 &Edit .&Global \ Settings .&Context \ Lines .\ 5 \ :set so = 5 < CR >
an 20 .440 .120 &Edit .&Global \ Settings .&Context \ Lines .\ 7 \ :set so = 7 < CR >
an 20 .440 .120 &Edit .&Global \ Settings .&Context \ Lines .\ 10 \ :set so = 10 < CR >
an 20 .440 .120 &Edit .&Global \ Settings .&Context \ Lines .\ 100 \ :set so = 100 < CR >
2004-06-13 20:20:40 +00:00
an 20 .440 .130 .40 &Edit .&Global \ Settings .&Virtual \ Edit .Never :set ve = < CR >
an 20 .440 .130 .50 &Edit .&Global \ Settings .&Virtual \ Edit .Block \ Selection :set ve = block < CR >
2017-03-05 17:04:09 +01:00
an 20 .440 .130 .60 &Edit .&Global \ Settings .&Virtual \ Edit .Insert \ Mode :set ve = insert < CR >
2004-06-13 20:20:40 +00:00
an 20 .440 .130 .70 &Edit .&Global \ Settings .&Virtual \ Edit .Block \ and \ Insert :set ve = block , insert < CR >
an 20 .440 .130 .80 &Edit .&Global \ Settings .&Virtual \ Edit .Always :set ve = all < CR >
an 20 .440 .140 &Edit .&Global \ Settings .Toggle \ Insert \ &Mode < Tab > :set \ im ! :set im ! < CR >
2017-03-05 17:04:09 +01:00
an 20 .440 .145 &Edit .&Global \ Settings .Toggle \ Vi \ C &ompatibility < Tab > :set \ cp ! :set cp ! < CR >
2004-06-13 20:20:40 +00:00
an < silent > 20 .440 .150 &Edit .&Global \ Settings .Search \ &Path \.\.\. :call < SID > SearchP ( ) < CR >
an < silent > 20 .440 .160 &Edit .&Global \ Settings .Ta &g \ Files \.\.\. :call < SID > TagFiles ( ) < CR >
"
" GUI options
an 20 .440 .300 &Edit .&Global \ Settings .- SEP1 - < Nop >
an < silent > 20 .440 .310 &Edit .&Global \ Settings .Toggle \ &Toolbar :call < SID > ToggleGuiOption ( "T" ) < CR >
an < silent > 20 .440 .320 &Edit .&Global \ Settings .Toggle \ &Bottom \ Scrollbar :call < SID > ToggleGuiOption ( "b" ) < CR >
an < silent > 20 .440 .330 &Edit .&Global \ Settings .Toggle \ &Left \ Scrollbar :call < SID > ToggleGuiOption ( "l" ) < CR >
an < silent > 20 .440 .340 &Edit .&Global \ Settings .Toggle \ &Right \ Scrollbar :call < SID > ToggleGuiOption ( "r" ) < CR >
2022-02-04 19:48:06 +00:00
def s :SearchP ( )
2004-06-13 20:20:40 +00:00
if ! exists ( "g:menutrans_path_dialog" )
2022-02-04 19:48:06 +00:00
g :menutrans_path_dialog = "Enter search path for files.\nSeparate directory names with a comma."
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
var n = inputdialog ( g :menutrans_path_dialog , substitute ( &path , '\\ ' , ' ' , 'g' ) )
2004-06-13 20:20:40 +00:00
if n ! = ""
2022-02-04 19:48:06 +00:00
&path = substitute ( n , ' ' , '\\ ' , 'g' )
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
enddef
2004-06-13 20:20:40 +00:00
2022-02-04 19:48:06 +00:00
def s :TagFiles ( )
2004-06-13 20:20:40 +00:00
if ! exists ( "g:menutrans_tags_dialog" )
2022-02-04 19:48:06 +00:00
g :menutrans_tags_dialog = "Enter names of tag files.\nSeparate the names with a comma."
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
var n = inputdialog ( g :menutrans_tags_dialog , substitute ( &tags , '\\ ' , ' ' , 'g' ) )
2004-06-13 20:20:40 +00:00
if n ! = ""
2022-02-04 19:48:06 +00:00
&tags = substitute ( n , ' ' , '\\ ' , 'g' )
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
enddef
2004-06-13 20:20:40 +00:00
2022-02-04 19:48:06 +00:00
def s :ToggleGuiOption ( option : string )
# If a :option is already set in guioptions , then we want to remove it
if match ( &guioptions , "\\C" .. option ) > -1
exec "set go-=" .. option
else
exec "set go+=" .. option
endif
enddef
2004-06-13 20:20:40 +00:00
" Edit/File Settings
" Boolean options
an 20 .440 .100 &Edit .F &ile \ Settings .Toggle \ Line \ &Numbering < Tab > :set \ nu ! :set nu ! nu ?< CR >
2017-03-05 17:04:09 +01:00
an 20 .440 .105 &Edit .F &ile \ Settings .Toggle \ Relati &ve \ Line \ Numbering < Tab > :set \ rnu ! :set rnu ! rnu ?< CR >
2004-06-13 20:20:40 +00:00
an 20 .440 .110 &Edit .F &ile \ Settings .Toggle \ &List \ Mode < Tab > :set \ list ! :set list ! list ?< CR >
2017-03-05 17:04:09 +01:00
an 20 .440 .120 &Edit .F &ile \ Settings .Toggle \ Line \ &Wrapping < Tab > :set \ wrap ! :set wrap ! wrap ?< CR >
an 20 .440 .130 &Edit .F &ile \ Settings .Toggle \ W &rapping \ at \ Word < Tab > :set \ lbr ! :set lbr ! lbr ?< CR >
an 20 .440 .160 &Edit .F &ile \ Settings .Toggle \ Tab \ &Expanding < Tab > :set \ et ! :set et ! et ?< CR >
an 20 .440 .170 &Edit .F &ile \ Settings .Toggle \ &Auto \ Indenting < Tab > :set \ ai ! :set ai ! ai ?< CR >
an 20 .440 .180 &Edit .F &ile \ Settings .Toggle \ &C - Style \ Indenting < Tab > :set \ cin ! :set cin ! cin ?< CR >
2004-06-13 20:20:40 +00:00
" other options
an 20 .440 .600 &Edit .F &ile \ Settings .- SEP2 - < Nop >
an 20 .440 .610 .20 &Edit .F &ile \ Settings .&Shiftwidth .2 :set sw = 2 sw ?< CR >
an 20 .440 .610 .30 &Edit .F &ile \ Settings .&Shiftwidth .3 :set sw = 3 sw ?< CR >
an 20 .440 .610 .40 &Edit .F &ile \ Settings .&Shiftwidth .4 :set sw = 4 sw ?< CR >
an 20 .440 .610 .50 &Edit .F &ile \ Settings .&Shiftwidth .5 :set sw = 5 sw ?< CR >
an 20 .440 .610 .60 &Edit .F &ile \ Settings .&Shiftwidth .6 :set sw = 6 sw ?< CR >
an 20 .440 .610 .80 &Edit .F &ile \ Settings .&Shiftwidth .8 :set sw = 8 sw ?< CR >
an 20 .440 .620 .20 &Edit .F &ile \ Settings .Soft \ &Tabstop .2 :set sts = 2 sts ?< CR >
an 20 .440 .620 .30 &Edit .F &ile \ Settings .Soft \ &Tabstop .3 :set sts = 3 sts ?< CR >
an 20 .440 .620 .40 &Edit .F &ile \ Settings .Soft \ &Tabstop .4 :set sts = 4 sts ?< CR >
an 20 .440 .620 .50 &Edit .F &ile \ Settings .Soft \ &Tabstop .5 :set sts = 5 sts ?< CR >
an 20 .440 .620 .60 &Edit .F &ile \ Settings .Soft \ &Tabstop .6 :set sts = 6 sts ?< CR >
an 20 .440 .620 .80 &Edit .F &ile \ Settings .Soft \ &Tabstop .8 :set sts = 8 sts ?< CR >
an < silent > 20 .440 .630 &Edit .F &ile \ Settings .Te &xt \ Width \.\.\. :call < SID > TextWidth ( ) < CR >
an < silent > 20 .440 .640 &Edit .F &ile \ Settings .&File \ Format \.\.\. :call < SID > FileFormat ( ) < CR >
2022-02-04 19:48:06 +00:00
def s :TextWidth ( )
2004-06-13 20:20:40 +00:00
if ! exists ( "g:menutrans_textwidth_dialog" )
2022-02-04 19:48:06 +00:00
g :menutrans_textwidth_dialog = "Enter new text width (0 to disable formatting): "
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
var n = inputdialog ( g :menutrans_textwidth_dialog , &tw .. '' )
2004-06-13 20:20:40 +00:00
if n ! = ""
2022-02-04 19:48:06 +00:00
# Remove leading zeros to avoid it being used as an octal number .
# But keep a zero by itself .
var tw = substitute ( n , "^0*" , "" , "" )
2022-11-27 15:51:46 +00:00
&tw = tw = = '' ? 0 : str2nr ( tw )
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
enddef
2004-06-13 20:20:40 +00:00
2022-02-04 19:48:06 +00:00
def s :FileFormat ( )
2004-06-13 20:20:40 +00:00
if ! exists ( "g:menutrans_fileformat_dialog" )
2022-02-04 19:48:06 +00:00
g :menutrans_fileformat_dialog = "Select format for writing the file"
2004-06-13 20:20:40 +00:00
endif
if ! exists ( "g:menutrans_fileformat_choices" )
2022-02-04 19:48:06 +00:00
g :menutrans_fileformat_choices = "&Unix\n&Dos\n&Mac\n&Cancel"
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
var def_choice : number
2004-06-13 20:20:40 +00:00
if &ff = = "dos"
2022-02-04 19:48:06 +00:00
def_choice = 2
2004-06-13 20:20:40 +00:00
elseif &ff = = "mac"
2022-02-04 19:48:06 +00:00
def_choice = 3
2004-06-13 20:20:40 +00:00
else
2022-02-04 19:48:06 +00:00
def_choice = 1
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
var n = confirm ( g :menutrans_fileformat_dialog , g :menutrans_fileformat_choices , def_choice , "Question" )
2004-06-13 20:20:40 +00:00
if n = = 1
set ff = unix
elseif n = = 2
set ff = dos
elseif n = = 3
set ff = mac
endif
2022-02-04 19:48:06 +00:00
enddef
2004-06-13 20:20:40 +00:00
2017-11-09 19:45:48 +01:00
let s :did_setup_color_schemes = 0
2010-07-17 15:20:30 +02:00
2004-06-13 20:20:40 +00:00
" Setup the Edit.Color Scheme submenu
2022-02-04 19:48:06 +00:00
def s :SetupColorSchemes ( )
2017-11-09 19:45:48 +01:00
if s :did_setup_color_schemes
return
endif
2022-02-04 19:48:06 +00:00
s :did_setup_color_schemes = 1
2010-07-17 15:20:30 +02:00
2022-02-04 19:48:06 +00:00
var n = globpath ( &runtimepath , "colors/*.vim" , 1 , 1 )
n + = globpath ( &packpath , "pack/*/start/*/colors/*.vim" , 1 , 1 )
n + = globpath ( &packpath , "pack/*/opt/*/colors/*.vim" , 1 , 1 )
2010-07-17 15:20:30 +02:00
2022-02-04 19:48:06 +00:00
# Ignore case for VMS and windows , sort on name
2022-02-23 13:17:47 +00:00
var names = sort ( map ( n , 'substitute(v:val, "\\c.*[/\\\\:\\]]\\([^/\\\\:]*\\)\\.vim", "\\1", "")' ) , 'i' )
2010-07-17 15:20:30 +02:00
2022-02-04 19:48:06 +00:00
# define all the submenu entries
var idx = 100
2017-11-09 19:45:48 +01:00
for name in names
2022-02-04 19:48:06 +00:00
exe "an 20.450." .. idx .. ' &Edit.C&olor\ Scheme.' .. name .. " :colors " .. name .. "<CR>"
idx + = 10
2017-11-09 19:45:48 +01:00
endfor
silent ! aunmenu &Edit .Show \ C &olor \ Schemes \ in \ Menu
2022-02-04 19:48:06 +00:00
enddef
2017-11-09 19:45:48 +01:00
if exists ( "do_no_lazyload_menus" )
call s :SetupColorSchemes ( )
else
an < silent > 20 .450 &Edit .Show \ C &olor \ Schemes \ in \ Menu :call < SID > SetupColorSchemes ( ) < CR >
endif
2010-07-17 15:20:30 +02:00
2004-06-13 20:20:40 +00:00
" Setup the Edit.Keymap submenu
if has ( "keymap" )
2017-11-09 19:45:48 +01:00
let s :did_setup_keymaps = 0
2022-02-04 19:48:06 +00:00
def s :SetupKeymaps ( )
2017-11-09 19:45:48 +01:00
if s :did_setup_keymaps
return
endif
2022-02-04 19:48:06 +00:00
s :did_setup_keymaps = 1
2017-11-09 19:45:48 +01:00
2022-02-04 19:48:06 +00:00
var names = globpath ( &runtimepath , "keymap/*.vim" , 1 , 1 )
if ! empty ( names )
var idx = 100
2017-11-09 19:45:48 +01:00
an 20 .460 .90 &Edit .&Keymap .None :set keymap = < CR >
2022-02-04 19:48:06 +00:00
for name in names
# Ignore case for VMS and windows
var mapname = substitute ( name , '\c.*[/\\:\]]\([^/\\:_]*\)\(_[0-9a-zA-Z-]*\)\=\.vim' , '\1' , '' )
exe "an 20.460." .. idx .. ' &Edit.&Keymap.' .. mapname .. " :set keymap=" .. mapname .. "<CR>"
idx + = 10
2017-11-09 19:45:48 +01:00
endfor
endif
silent ! aunmenu &Edit .Show \ &Keymaps \ in \ Menu
2022-02-04 19:48:06 +00:00
enddef
2017-11-09 19:45:48 +01:00
if exists ( "do_no_lazyload_menus" )
call s :SetupKeymaps ( )
else
an < silent > 20 .460 &Edit .Show \ &Keymaps \ in \ Menu :call < SID > SetupKeymaps ( ) < CR >
2004-06-13 20:20:40 +00:00
endif
endif
2022-02-04 19:48:06 +00:00
2017-11-09 19:45:48 +01:00
if has ( "win32" ) | | has ( "gui_motif" ) | | has ( "gui_gtk" ) | | has ( "gui_kde" ) | | has ( "gui_photon" ) | | has ( "gui_mac" )
2004-06-13 20:20:40 +00:00
an 20 .470 &Edit .Select \ Fo &nt \.\.\. :set guifont = *< CR >
endif
" Programming menu
if ! exists ( "g:ctags_command" )
if has ( "vms" )
2007-01-09 14:09:25 +00:00
let g :ctags_command = "mc vim:ctags *.*"
2004-06-13 20:20:40 +00:00
else
let g :ctags_command = "ctags -R ."
endif
endif
2017-03-05 17:04:09 +01:00
an 40 .300 &Tools .&Jump \ to \ This \ Tag < Tab > g ^] g < C - ]>
vunmenu &Tools .&Jump \ to \ This \ Tag < Tab > g ^]
vnoremenu &Tools .&Jump \ to \ This \ Tag < Tab > g ^] g < C - ]>
an 40 .310 &Tools .Jump \ &Back < Tab > ^T < C - T >
2022-02-04 19:48:06 +00:00
an 40 .320 &Tools .Build \ &Tags \ File :exe "!" .. g :ctags_command < CR >
2004-06-13 20:20:40 +00:00
2005-06-07 21:09:25 +00:00
if has ( "folding" ) | | has ( "spell" )
an 40 .330 &Tools .- SEP1 - < Nop >
endif
2005-06-08 22:03:13 +00:00
" Tools.Spelling Menu
2005-06-07 21:09:25 +00:00
if has ( "spell" )
an 40 .335 .110 &Tools .&Spelling .&Spell \ Check \ On :set spell < CR >
an 40 .335 .120 &Tools .&Spelling .Spell \ Check \ &Off :set nospell < CR >
2017-03-05 17:04:09 +01:00
an 40 .335 .130 &Tools .&Spelling .To \ &Next \ Error < Tab > ]s ]s
an 40 .335 .130 &Tools .&Spelling .To \ &Previous \ Error < Tab > [s [s
2006-03-06 23:29:24 +00:00
an 40 .335 .140 &Tools .&Spelling .Suggest \ &Corrections < Tab > z = z =
2017-03-05 17:04:09 +01:00
an 40 .335 .150 &Tools .&Spelling .&Repeat \ Correction < Tab > :spellrepall :spellrepall < CR >
2005-06-07 21:09:25 +00:00
an 40 .335 .200 &Tools .&Spelling .- SEP1 - < Nop >
2017-03-05 17:04:09 +01:00
an 40 .335 .210 &Tools .&Spelling .Set \ Language \ to \ "en" :set spl = en spell < CR >
an 40 .335 .220 &Tools .&Spelling .Set \ Language \ to \ "en_au" :set spl = en_au spell < CR >
an 40 .335 .230 &Tools .&Spelling .Set \ Language \ to \ "en_ca" :set spl = en_ca spell < CR >
an 40 .335 .240 &Tools .&Spelling .Set \ Language \ to \ "en_gb" :set spl = en_gb spell < CR >
an 40 .335 .250 &Tools .&Spelling .Set \ Language \ to \ "en_nz" :set spl = en_nz spell < CR >
an 40 .335 .260 &Tools .&Spelling .Set \ Language \ to \ "en_us" :set spl = en_us spell < CR >
2005-06-07 21:09:25 +00:00
an < silent > 40 .335 .270 &Tools .&Spelling .&Find \ More \ Languages :call < SID > SpellLang ( ) < CR >
2020-06-14 17:29:55 +02:00
let s :undo_spelllang = ['aun &Tools.&Spelling.&Find\ More\ Languages' ]
2022-11-27 16:18:33 +00:00
def s :SpellLang ( encChanged = false )
2020-06-14 17:29:55 +02:00
for cmd in s :undo_spelllang
2022-02-04 19:48:06 +00:00
exe "silent! " .. cmd
2005-07-30 22:43:24 +00:00
endfor
2022-02-04 19:48:06 +00:00
s :undo_spelllang = []
2005-07-30 22:43:24 +00:00
2022-02-04 19:48:06 +00:00
var enc = &enc = = "iso-8859-15" ? "latin1" : &enc
2005-07-30 22:43:24 +00:00
2022-11-27 16:18:33 +00:00
# Reset g :menutrans_set_lang_to when called for the EncodingChanged event .
if ! exists ( "g:menutrans_set_lang_to" ) | | encChanged
2022-02-04 19:48:06 +00:00
g :menutrans_set_lang_to = 'Set Language to'
2012-10-21 01:21:59 +02:00
endif
2022-02-04 19:48:06 +00:00
var found = 0
var _nm = ''
var names = globpath ( &runtimepath , "spell/*." .. enc .. ".spl" , 1 , 1 )
if ! empty ( names )
var n = 300
for f in names
var nm = substitute ( f , '.*spell[/\\]\(..\)\.[^/\\]*\.spl' , '\1' , "" )
2005-07-30 22:43:24 +00:00
if nm ! = "en" && nm ! ~ '/'
2022-02-04 19:48:06 +00:00
_nm = nm
found + = 1
var menuname = '&Tools.&Spelling.' .. escape ( g :menutrans_set_lang_to , "\\. \t|" ) .. '\ "' .. nm .. '"'
exe 'an 40.335.' .. n .. ' ' .. menuname .. ' :set spl=' .. nm .. ' spell<CR>'
s :undo_spelllang + = ['aun ' .. menuname ]
2005-06-07 21:09:25 +00:00
endif
2022-02-04 19:48:06 +00:00
n + = 10
2005-06-07 21:09:25 +00:00
endfor
endif
if found = = 0
echomsg "Could not find other spell files"
elseif found = = 1
2022-02-04 19:48:06 +00:00
echomsg "Found spell file " .. _nm
2005-06-07 21:09:25 +00:00
else
2022-02-04 19:48:06 +00:00
echomsg "Found " .. found .. " more spell files"
2005-06-07 21:09:25 +00:00
endif
2022-11-27 16:18:33 +00:00
2022-02-04 19:48:06 +00:00
# Need to redo this when 'encoding' is changed .
2005-07-30 22:43:24 +00:00
augroup spellmenu
2022-11-27 16:18:33 +00:00
au ! EncodingChanged * call SpellLang ( true )
2005-07-30 22:43:24 +00:00
augroup END
2022-02-04 19:48:06 +00:00
enddef
2005-06-07 21:09:25 +00:00
endif
2004-06-13 20:20:40 +00:00
" Tools.Fold Menu
if has ( "folding" )
" open close folds
2017-03-05 17:04:09 +01:00
an 40 .340 .110 &Tools .&Folding .&Enable /Disable \ Folds < Tab > zi zi
2004-06-13 20:20:40 +00:00
an 40 .340 .120 &Tools .&Folding .&View \ Cursor \ Line < Tab > zv zv
2017-03-05 17:04:09 +01:00
an 40 .340 .120 &Tools .&Folding .Vie &w \ Cursor \ Line \ Only < Tab > zMzx zMzx
inoremenu 40 .340 .120 &Tools .&Folding .Vie &w \ Cursor \ Line \ Only < Tab > zMzx < C - O > zM < C - O > zx
an 40 .340 .130 &Tools .&Folding .C &lose \ More \ Folds < Tab > zm zm
an 40 .340 .140 &Tools .&Folding .&Close \ All \ Folds < Tab > zM zM
an 40 .340 .150 &Tools .&Folding .O &pen \ More \ Folds < Tab > zr zr
2017-02-17 22:47:16 +01:00
an 40 .340 .160 &Tools .&Folding .&Open \ All \ Folds < Tab > zR zR
2004-06-13 20:20:40 +00:00
" fold method
an 40 .340 .200 &Tools .&Folding .- SEP1 - < Nop >
an 40 .340 .210 &Tools .&Folding .Fold \ Met &hod .M &anual :set fdm = manual < CR >
an 40 .340 .210 &Tools .&Folding .Fold \ Met &hod .I &ndent :set fdm = indent < CR >
an 40 .340 .210 &Tools .&Folding .Fold \ Met &hod .E &xpression :set fdm = expr < CR >
an 40 .340 .210 &Tools .&Folding .Fold \ Met &hod .S &yntax :set fdm = syntax < CR >
an 40 .340 .210 &Tools .&Folding .Fold \ Met &hod .&Diff :set fdm = diff < CR >
an 40 .340 .210 &Tools .&Folding .Fold \ Met &hod .Ma &rker :set fdm = marker < CR >
" create and delete folds
vnoremenu 40 .340 .220 &Tools .&Folding .Create \ &Fold < Tab > zf zf
an 40 .340 .230 &Tools .&Folding .&Delete \ Fold < Tab > zd zd
an 40 .340 .240 &Tools .&Folding .Delete \ &All \ Folds < Tab > zD zD
" moving around in folds
an 40 .340 .300 &Tools .&Folding .- SEP2 - < Nop >
2017-03-05 17:04:09 +01:00
an 40 .340 .310 .10 &Tools .&Folding .Fold \ Col &umn \ Width .\ &0 \ :set fdc = 0 < CR >
an 40 .340 .310 .20 &Tools .&Folding .Fold \ Col &umn \ Width .\ &2 \ :set fdc = 2 < CR >
an 40 .340 .310 .30 &Tools .&Folding .Fold \ Col &umn \ Width .\ &3 \ :set fdc = 3 < CR >
an 40 .340 .310 .40 &Tools .&Folding .Fold \ Col &umn \ Width .\ &4 \ :set fdc = 4 < CR >
an 40 .340 .310 .50 &Tools .&Folding .Fold \ Col &umn \ Width .\ &5 \ :set fdc = 5 < CR >
an 40 .340 .310 .60 &Tools .&Folding .Fold \ Col &umn \ Width .\ &6 \ :set fdc = 6 < CR >
an 40 .340 .310 .70 &Tools .&Folding .Fold \ Col &umn \ Width .\ &7 \ :set fdc = 7 < CR >
an 40 .340 .310 .80 &Tools .&Folding .Fold \ Col &umn \ Width .\ &8 \ :set fdc = 8 < CR >
2004-06-13 20:20:40 +00:00
endif " has folding
if has ( "diff" )
an 40 .350 .100 &Tools .&Diff .&Update :diffupdate < CR >
an 40 .350 .110 &Tools .&Diff .&Get \ Block :diffget < CR >
vunmenu &Tools .&Diff .&Get \ Block
vnoremenu &Tools .&Diff .&Get \ Block :diffget < CR >
an 40 .350 .120 &Tools .&Diff .&Put \ Block :diffput < CR >
vunmenu &Tools .&Diff .&Put \ Block
vnoremenu &Tools .&Diff .&Put \ Block :diffput < CR >
endif
an 40 .358 &Tools .- SEP2 - < Nop >
an 40 .360 &Tools .&Make < Tab > :make :make < CR >
an 40 .370 &Tools .&List \ Errors < Tab > :cl :cl < CR >
an 40 .380 &Tools .L &ist \ Messages < Tab > :cl ! :cl ! < CR >
an 40 .390 &Tools .&Next \ Error < Tab > :cn :cn < CR >
an 40 .400 &Tools .&Previous \ Error < Tab > :cp :cp < CR >
an 40 .410 &Tools .&Older \ List < Tab > :cold :colder < CR >
an 40 .420 &Tools .N &ewer \ List < Tab > :cnew :cnewer < CR >
an 40 .430 .50 &Tools .Error \ &Window .&Update < Tab > :cwin :cwin < CR >
an 40 .430 .60 &Tools .Error \ &Window .&Open < Tab > :copen :copen < CR >
an 40 .430 .70 &Tools .Error \ &Window .&Close < Tab > :cclose :cclose < CR >
an 40 .520 &Tools .- SEP3 - < Nop >
an < silent > 40 .530 &Tools .&Convert \ to \ HEX < Tab > :%! xxd
\ :call < SID > XxdConv ( ) < CR >
2017-03-05 17:04:09 +01:00
an < silent > 40 .540 &Tools .Conve &rt \ Back < Tab > :%! xxd \ - r
2004-06-13 20:20:40 +00:00
\ :call < SID > XxdBack ( ) < CR >
" Use a function to do the conversion, so that it also works with 'insertmode'
" set.
2022-02-04 19:48:06 +00:00
def s :XxdConv ( )
var mod = &mod
2004-06-13 20:20:40 +00:00
if has ( "vms" )
2022-02-04 19:48:06 +00:00
:%! mc vim :xxd
2004-06-13 20:20:40 +00:00
else
2022-02-04 19:48:06 +00:00
s :XxdFind ( )
2022-03-08 21:35:07 +00:00
exe ':%!' .. g :xxdprogram
2004-06-13 20:20:40 +00:00
endif
2022-03-08 21:35:07 +00:00
if getline ( 1 ) = ~ "^00000000:" # only if it worked
2004-06-13 20:20:40 +00:00
set ft = xxd
endif
2022-02-04 19:48:06 +00:00
&mod = mod
enddef
2004-06-13 20:20:40 +00:00
2022-02-04 19:48:06 +00:00
def s :XxdBack ( )
var mod = &mod
2004-06-13 20:20:40 +00:00
if has ( "vms" )
2022-02-04 19:48:06 +00:00
:%! mc vim :xxd - r
2004-06-13 20:20:40 +00:00
else
2022-02-04 19:48:06 +00:00
s :XxdFind ( )
2022-03-08 21:35:07 +00:00
exe ':%!' .. g :xxdprogram .. ' -r'
2004-06-13 20:20:40 +00:00
endif
set ft =
2023-05-14 18:50:25 +01:00
if exists ( '#filetypedetect' ) && exists ( '#BufReadPost' )
doautocmd filetypedetect BufReadPost
endif
2022-02-04 19:48:06 +00:00
&mod = mod
enddef
2004-06-13 20:20:40 +00:00
2022-02-04 19:48:06 +00:00
def s :XxdFind ( )
2004-06-13 20:20:40 +00:00
if ! exists ( "g:xxdprogram" )
2022-02-04 19:48:06 +00:00
# On the PC xxd may not be in the path but in the install directory
2016-07-17 13:35:14 +02:00
if has ( "win32" ) && ! executable ( "xxd" )
2022-02-04 19:48:06 +00:00
g :xxdprogram = $VIMRUNTIME .. ( &shellslash ? '/' : '\' ) .. "xxd.exe"
2019-11-10 22:09:11 +01:00
if g :xxdprogram = ~ ' '
2022-02-04 19:48:06 +00:00
g :xxdprogram = '"' .. g :xxdprogram .. '"'
2019-11-10 22:09:11 +01:00
endif
2004-06-13 20:20:40 +00:00
else
2022-02-04 19:48:06 +00:00
g :xxdprogram = "xxd"
2004-06-13 20:20:40 +00:00
endif
endif
2022-02-04 19:48:06 +00:00
enddef
2004-06-13 20:20:40 +00:00
2017-11-09 19:45:48 +01:00
let s :did_setup_compilers = 0
2004-06-13 20:20:40 +00:00
" Setup the Tools.Compiler submenu
2022-02-04 19:48:06 +00:00
def s :SetupCompilers ( )
2017-11-09 19:45:48 +01:00
if s :did_setup_compilers
return
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
s :did_setup_compilers = 1
var names = globpath ( &runtimepath , "compiler/*.vim" , 1 , 1 )
var idx = 100
for name in names
# Ignore case for VMS and windows
var cname = substitute ( name , '\c.*[/\\:\]]\([^/\\:]*\)\.vim' , '\1' , '' )
exe "an 30.440." .. idx .. ' &Tools.Se&t\ Compiler.' .. cname .. " :compiler " .. cname .. "<CR>"
idx + = 10
2017-11-09 19:45:48 +01:00
endfor
silent ! aunmenu &Tools .Show \ Compiler \ Se &ttings \ in \ Menu
2022-02-04 19:48:06 +00:00
enddef
2017-11-09 19:45:48 +01:00
if exists ( "do_no_lazyload_menus" )
call s :SetupCompilers ( )
else
an < silent > 30 .440 &Tools .Show \ Compiler \ Se &ttings \ in \ Menu :call < SID > SetupCompilers ( ) < CR >
endif
" Load ColorScheme, Compiler Setting and Keymap menus when idle.
if ! exists ( "do_no_lazyload_menus" )
2022-02-04 19:48:06 +00:00
def s :SetupLazyloadMenus ( )
s :SetupColorSchemes ( )
s :SetupCompilers ( )
2017-11-09 19:45:48 +01:00
if has ( "keymap" )
2022-02-04 19:48:06 +00:00
s :SetupKeymaps ( )
2017-11-09 19:45:48 +01:00
endif
2022-02-04 19:48:06 +00:00
enddef
2017-11-09 19:45:48 +01:00
augroup SetupLazyloadMenus
au !
au CursorHold , CursorHoldI * call < SID > SetupLazyloadMenus ( ) | au ! SetupLazyloadMenus
augroup END
endif
2004-06-13 20:20:40 +00:00
if ! exists ( "no_buffers_menu" )
" Buffer list menu -- Setup functions & actions
" wait with building the menu until after loading 'session' files. Makes
" startup faster.
let s :bmenu_wait = 1
2020-03-19 18:46:57 +01:00
" Dictionary of buffer number to name. This helps prevent problems where a
" buffer as renamed and we didn't keep track of that.
let s :bmenu_items = {}
2004-06-13 20:20:40 +00:00
if ! exists ( "bmenu_priority" )
let bmenu_priority = 60
endif
2020-03-19 18:46:57 +01:00
" invoked from a BufCreate or BufFilePost autocommand
2022-02-04 19:48:06 +00:00
def s :BMAdd ( )
2004-06-13 20:20:40 +00:00
if s :bmenu_wait = = 0
2022-02-04 19:48:06 +00:00
# when adding too many buffers , redraw in short format
2004-06-13 20:20:40 +00:00
if s :bmenu_count = = &menuitems && s :bmenu_short = = 0
2022-02-04 19:48:06 +00:00
s :BMShow ( )
2004-06-13 20:20:40 +00:00
else
2022-02-04 19:48:06 +00:00
var name = expand ( "<afile>" )
var num = str2nr ( expand ( "<abuf>" ) )
2020-03-19 18:46:57 +01:00
if s :BMCanAdd ( name , num )
2022-02-04 19:48:06 +00:00
s :BMFilename ( name , num )
s :bmenu_count + = 1
2020-03-19 18:46:57 +01:00
endif
2004-06-13 20:20:40 +00:00
endif
endif
2022-02-04 19:48:06 +00:00
enddef
2004-06-13 20:20:40 +00:00
2020-03-19 18:46:57 +01:00
" invoked from a BufDelete or BufFilePre autocommand
2022-02-04 19:48:06 +00:00
def s :BMRemove ( )
2004-06-13 20:20:40 +00:00
if s :bmenu_wait = = 0
2022-02-04 19:48:06 +00:00
var bufnum = expand ( "<abuf>" )
2020-03-19 18:46:57 +01:00
if s :bmenu_items - > has_key ( bufnum )
2022-02-04 19:48:06 +00:00
var menu_name = s :bmenu_items [bufnum ]
exe 'silent! aun &Buffers.' .. menu_name
s :bmenu_count = s :bmenu_count - 1
2020-03-19 18:46:57 +01:00
unlet s :bmenu_items [bufnum ]
2004-06-13 20:20:40 +00:00
endif
2020-03-19 18:46:57 +01:00
endif
2022-02-04 19:48:06 +00:00
enddef
2004-06-13 20:20:40 +00:00
2020-03-19 18:46:57 +01:00
" Return non-zero if buffer with number "name" / "num" is useful to add in the
" buffer menu.
2022-02-04 19:48:06 +00:00
def s :BMCanAdd ( name : string , num : number ) : bool
# no directory or unlisted buffer
if isdirectory ( name ) | | ! buflisted ( num )
return false
2020-03-19 18:46:57 +01:00
endif
2022-02-04 19:48:06 +00:00
# no name with control characters
if name = ~ '[\x01-\x1f]'
return false
2021-12-24 13:18:38 +00:00
endif
2022-02-04 19:48:06 +00:00
# no special buffer , such as terminal or popup
var buftype = getbufvar ( num , '&buftype' )
2020-03-19 18:46:57 +01:00
if buftype ! = '' && buftype ! = 'nofile' && buftype ! = 'nowrite'
2022-02-04 19:48:06 +00:00
return false
2004-06-13 20:20:40 +00:00
endif
2020-03-19 18:46:57 +01:00
2022-02-04 19:48:06 +00:00
# only existing buffers
return bufexists ( num )
enddef
2004-06-13 20:20:40 +00:00
" Create the buffer menu (delete an existing one first).
2022-02-04 19:48:06 +00:00
def s :BMShow ( )
s :bmenu_wait = 1
s :bmenu_short = 1
s :bmenu_count = 0
s :bmenu_items = {}
# Remove old menu , if it exists ; keep one entry to avoid a torn off menu to
# disappear . Use try /catch to avoid setting v :errmsg
try
unmenu &Buffers
catch
endtry
exe 'noremenu ' .. g :bmenu_priority .. ".1 &Buffers.Dummy l"
try
unmenu ! &Buffers
catch
endtry
# create new menu
exe 'an <silent> ' .. g :bmenu_priority .. ".2 &Buffers.&Refresh\\ menu :call <SID>BMShow()<CR>"
exe 'an ' .. g :bmenu_priority .. ".4 &Buffers.&Delete :confirm bd<CR>"
exe 'an ' .. g :bmenu_priority .. ".6 &Buffers.&Alternate :confirm b #<CR>"
exe 'an ' .. g :bmenu_priority .. ".7 &Buffers.&Next :confirm bnext<CR>"
exe 'an ' .. g :bmenu_priority .. ".8 &Buffers.&Previous :confirm bprev<CR>"
exe 'an ' .. g :bmenu_priority .. ".9 &Buffers.-SEP- :"
2004-06-13 20:20:40 +00:00
unmenu &Buffers .Dummy
2022-02-04 19:48:06 +00:00
# figure out how many buffers there are
var buf = 1
2004-06-13 20:20:40 +00:00
while buf < = bufnr ( '$' )
2020-03-19 18:46:57 +01:00
if s :BMCanAdd ( bufname ( buf ) , buf )
2022-02-04 19:48:06 +00:00
s :bmenu_count = s :bmenu_count + 1
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
buf + = 1
2004-06-13 20:20:40 +00:00
endwhile
if s :bmenu_count < = &menuitems
2022-02-04 19:48:06 +00:00
s :bmenu_short = 0
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
# iterate through buffer list , adding each buffer to the menu :
buf = 1
2004-06-13 20:20:40 +00:00
while buf < = bufnr ( '$' )
2022-02-04 19:48:06 +00:00
var name = bufname ( buf )
2020-03-19 18:46:57 +01:00
if s :BMCanAdd ( name , buf )
2022-02-04 19:48:06 +00:00
call s :BMFilename ( name , buf )
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
buf + = 1
2004-06-13 20:20:40 +00:00
endwhile
2022-02-04 19:48:06 +00:00
s :bmenu_wait = 0
2004-06-13 20:20:40 +00:00
aug buffer_list
2022-02-04 19:48:06 +00:00
au !
au BufCreate , BufFilePost * call s :BMAdd ( )
au BufDelete , BufFilePre * call s :BMRemove ( )
2004-06-13 20:20:40 +00:00
aug END
2022-02-04 19:48:06 +00:00
enddef
2004-06-13 20:20:40 +00:00
2022-02-04 19:48:06 +00:00
def s :BMHash ( name : string ) : number
# Make name all upper case , so that chars are between 32 and 96
var nm = substitute ( name , ".*" , '\U\0' , "" )
var sp : number
2004-06-13 20:20:40 +00:00
if has ( "ebcdic" )
2022-02-04 19:48:06 +00:00
# HACK : Replace all non alphabetics with 'Z'
# Just to make it work for now .
nm = substitute ( nm , "[^A-Z]" , 'Z' , "g" )
sp = char2nr ( 'A' ) - 1
2004-06-13 20:20:40 +00:00
else
2022-02-04 19:48:06 +00:00
sp = char2nr ( ' ' )
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
# convert first six chars into a number for sorting :
2004-06-13 20:20:40 +00:00
return ( char2nr ( nm [0 ]) - sp ) * 0 x800000 + ( char2nr ( nm [1 ]) - sp ) * 0 x20000 + ( char2nr ( nm [2 ]) - sp ) * 0 x1000 + ( char2nr ( nm [3 ]) - sp ) * 0 x80 + ( char2nr ( nm [4 ]) - sp ) * 0 x20 + ( char2nr ( nm [5 ]) - sp )
2022-02-04 19:48:06 +00:00
enddef
2004-06-13 20:20:40 +00:00
2022-02-04 19:48:06 +00:00
def s :BMHash2 ( name : string ) : string
var nm = substitute ( name , "." , '\L\0' , "" )
2004-06-13 20:20:40 +00:00
if nm [0 ] < 'a' | | nm [0 ] > 'z'
return '&others.'
elseif nm [0 ] < = 'd'
return '&abcd.'
elseif nm [0 ] < = 'h'
return '&efgh.'
elseif nm [0 ] < = 'l'
return '&ijkl.'
elseif nm [0 ] < = 'p'
return '&mnop.'
elseif nm [0 ] < = 't'
return '&qrst.'
else
return '&u-z.'
endif
2022-02-04 19:48:06 +00:00
enddef
2004-06-13 20:20:40 +00:00
2020-03-19 18:46:57 +01:00
" Insert a buffer name into the buffer menu.
2022-02-04 19:48:06 +00:00
def s :BMFilename ( name : string , num : number )
var munge = s :BMMunge ( name , num )
var hash = s :BMHash ( munge )
var cmd : string
2004-06-13 20:20:40 +00:00
if s :bmenu_short = = 0
2022-02-04 19:48:06 +00:00
s :bmenu_items [num ] = munge
cmd = 'an ' .. g :bmenu_priority .. '.' .. hash .. ' &Buffers.' .. munge
2004-06-13 20:20:40 +00:00
else
2022-02-04 19:48:06 +00:00
var menu_name = s :BMHash2 ( munge ) .. munge
s :bmenu_items [num ] = menu_name
cmd = 'an ' .. g :bmenu_priority .. '.' .. hash .. '.' .. hash .. ' &Buffers.' .. menu_name
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
exe cmd .. ' :confirm b' .. num .. '<CR>'
enddef
2004-06-13 20:20:40 +00:00
" Truncate a long path to fit it in a menu item.
if ! exists ( "g:bmenu_max_pathlen" )
let g :bmenu_max_pathlen = 35
endif
2022-02-04 19:48:06 +00:00
def s :BMTruncName ( fname : string ) : string
var name = fname
2004-06-13 20:20:40 +00:00
if g :bmenu_max_pathlen < 5
2022-02-04 19:48:06 +00:00
name = ""
2004-06-13 20:20:40 +00:00
else
2022-02-04 19:48:06 +00:00
var len = strlen ( name )
2004-06-13 20:20:40 +00:00
if len > g :bmenu_max_pathlen
2022-02-04 19:48:06 +00:00
var amountl = ( g :bmenu_max_pathlen / 2 ) - 2
var amountr = g :bmenu_max_pathlen - amountl - 3
var pattern = '^\(.\{,' .. amountl .. '}\).\{-}\(.\{,' .. amountr .. '}\)$'
var left = substitute ( name , pattern , '\1' , '' )
var right = substitute ( name , pattern , '\2' , '' )
2004-06-13 20:20:40 +00:00
if strlen ( left ) + strlen ( right ) < len
2022-02-04 19:48:06 +00:00
name = left .. '...' .. right
2004-06-13 20:20:40 +00:00
endif
endif
endif
return name
2022-02-04 19:48:06 +00:00
enddef
2004-06-13 20:20:40 +00:00
2022-02-04 19:48:06 +00:00
def s :BMMunge ( fname : string , bnum : number ) : string
var name = fname
2004-06-13 20:20:40 +00:00
if name = = ''
if ! exists ( "g:menutrans_no_file" )
2022-02-04 19:48:06 +00:00
g :menutrans_no_file = "[No Name]"
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
name = g :menutrans_no_file
2004-06-13 20:20:40 +00:00
else
2022-02-04 19:48:06 +00:00
name = fnamemodify ( name , ':p:~' )
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
# detach file name and separate it out :
var name2 = fnamemodify ( name , ':t' )
if bnum > = 0
name2 = name2 .. ' (' .. bnum .. ')'
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
name = name2 .. "\t" .. s :BMTruncName ( fnamemodify ( name , ':h' ) )
name = escape ( name , "\\. \t|" )
name = substitute ( name , "&" , "&&" , "g" )
name = substitute ( name , "\n" , "^@" , "g" )
2004-06-13 20:20:40 +00:00
return name
2022-02-04 19:48:06 +00:00
enddef
2004-06-13 20:20:40 +00:00
" When just starting Vim, load the buffer menu later
if has ( "vim_starting" )
augroup LoadBufferMenu
au ! VimEnter * if ! exists ( "no_buffers_menu" ) | call < SID > BMShow ( ) | endif
au VimEnter * au ! LoadBufferMenu
augroup END
else
call < SID > BMShow ( )
endif
endif " !exists(" no_buffers_menu ")
" Window menu
an 70 .300 &Window .&New < Tab > ^Wn < C - W > n
an 70 .310 &Window .S &plit < Tab > ^Ws < C - W > s
an 70 .320 &Window .Sp &lit \ To \ #< Tab > ^W ^^ < C - W > < C - ^>
an 70 .330 &Window .Split \ &Vertically < Tab > ^Wv < C - W > v
2019-02-03 15:27:20 +01:00
an < silent > 70 .332 &Window .Split \ File \ E &xplorer :call MenuExplOpen ( ) < CR >
if ! exists ( "*MenuExplOpen" )
2022-02-04 19:48:06 +00:00
def MenuExplOpen ( )
2019-02-03 15:27:20 +01:00
if @% = = ""
2022-02-04 19:48:06 +00:00
:20 vsp .
2019-02-03 15:27:20 +01:00
else
2022-02-04 19:48:06 +00:00
exe ":20vsp " .. fnameescape ( expand ( "%:p:h" ) )
2019-02-03 15:27:20 +01:00
endif
2022-02-04 19:48:06 +00:00
enddef
2004-06-13 20:20:40 +00:00
endif
an 70 .335 &Window .- SEP1 - < Nop >
an 70 .340 &Window .&Close < Tab > ^Wc :confirm close < CR >
an 70 .345 &Window .Close \ &Other ( s ) < Tab > ^Wo :confirm only < CR >
an 70 .350 &Window .- SEP2 - < Nop >
an 70 .355 &Window .Move \ &To .&Top < Tab > ^WK < C - W > K
an 70 .355 &Window .Move \ &To .&Bottom < Tab > ^WJ < C - W > J
2017-03-05 17:04:09 +01:00
an 70 .355 &Window .Move \ &To .&Left \ Side < Tab > ^WH < C - W > H
an 70 .355 &Window .Move \ &To .&Right \ Side < Tab > ^WL < C - W > L
2004-06-13 20:20:40 +00:00
an 70 .360 &Window .Rotate \ &Up < Tab > ^WR < C - W > R
an 70 .362 &Window .Rotate \ &Down < Tab > ^Wr < C - W > r
an 70 .365 &Window .- SEP3 - < Nop >
an 70 .370 &Window .&Equal \ Size < Tab > ^W = < C - W > =
an 70 .380 &Window .&Max \ Height < Tab > ^W_ < C - W > _
an 70 .390 &Window .M &in \ Height < Tab > ^W1_ < C - W > 1 _
an 70 .400 &Window .Max \ &Width < Tab > ^W \| < C - W > \|
an 70 .410 &Window .Min \ Widt &h < Tab > ^W1 \| < C - W > 1 \|
" The popup menu
an 1 .10 PopUp .&Undo u
an 1 .15 PopUp .- SEP1 - < Nop >
vnoremenu 1 .20 PopUp .Cu &t "+x
vnoremenu 1 .30 PopUp .&Copy "+y
cnoremenu 1 .30 PopUp .&Copy < C - Y >
nnoremenu 1 .40 PopUp .&Paste "+gP
cnoremenu 1 .40 PopUp .&Paste < C - R > +
2022-02-04 19:48:06 +00:00
exe 'vnoremenu <script> 1.40 PopUp.&Paste ' .. paste #paste_cmd ['v' ]
exe 'inoremenu <script> 1.40 PopUp.&Paste ' .. paste #paste_cmd ['i' ]
2004-06-13 20:20:40 +00:00
vnoremenu 1 .50 PopUp .&Delete x
an 1 .55 PopUp .- SEP2 - < Nop >
vnoremenu 1 .60 PopUp .Select \ Blockwise < C - V >
2004-12-09 21:34:53 +00:00
nnoremenu 1 .70 PopUp .Select \ &Word vaw
onoremenu 1 .70 PopUp .Select \ &Word aw
vnoremenu 1 .70 PopUp .Select \ &Word < C - C > vaw
inoremenu 1 .70 PopUp .Select \ &Word < C - O > vaw
cnoremenu 1 .70 PopUp .Select \ &Word < C - C > vaw
nnoremenu 1 .73 PopUp .Select \ &Sentence vas
onoremenu 1 .73 PopUp .Select \ &Sentence as
vnoremenu 1 .73 PopUp .Select \ &Sentence < C - C > vas
inoremenu 1 .73 PopUp .Select \ &Sentence < C - O > vas
cnoremenu 1 .73 PopUp .Select \ &Sentence < C - C > vas
nnoremenu 1 .77 PopUp .Select \ Pa &ragraph vap
onoremenu 1 .77 PopUp .Select \ Pa &ragraph ap
vnoremenu 1 .77 PopUp .Select \ Pa &ragraph < C - C > vap
inoremenu 1 .77 PopUp .Select \ Pa &ragraph < C - O > vap
cnoremenu 1 .77 PopUp .Select \ Pa &ragraph < C - C > vap
nnoremenu 1 .80 PopUp .Select \ &Line V
onoremenu 1 .80 PopUp .Select \ &Line < C - C > V
vnoremenu 1 .80 PopUp .Select \ &Line < C - C > V
inoremenu 1 .80 PopUp .Select \ &Line < C - O > V
cnoremenu 1 .80 PopUp .Select \ &Line < C - C > V
nnoremenu 1 .90 PopUp .Select \ &Block < C - V >
onoremenu 1 .90 PopUp .Select \ &Block < C - C > < C - V >
vnoremenu 1 .90 PopUp .Select \ &Block < C - C > < C - V >
inoremenu 1 .90 PopUp .Select \ &Block < C - O > < C - V >
cnoremenu 1 .90 PopUp .Select \ &Block < C - C > < C - V >
2004-06-13 20:20:40 +00:00
noremenu < script > < silent > 1 .100 PopUp .Select \ &All :< C - U > call < SID > SelectAll ( ) < CR >
inoremenu < script > < silent > 1 .100 PopUp .Select \ &All < C - O > :call < SID > SelectAll ( ) < CR >
cnoremenu < script > < silent > 1 .100 PopUp .Select \ &All < C - U > call < SID > SelectAll ( ) < CR >
2005-07-21 21:08:21 +00:00
if has ( "spell" )
" Spell suggestions in the popup menu. Note that this will slow down the
" appearance of the menu!
2022-02-04 19:48:06 +00:00
def s :SpellPopup ( )
2005-07-21 21:08:21 +00:00
if exists ( "s:changeitem" ) && s :changeitem ! = ''
2022-02-04 19:48:06 +00:00
call s :SpellDel ( )
2005-07-21 21:08:21 +00:00
endif
2006-09-14 11:35:25 +00:00
2022-02-04 19:48:06 +00:00
# Return quickly if spell checking is not enabled .
2005-07-22 21:52:15 +00:00
if ! &spell | | &spelllang = = ''
return
endif
2005-07-21 21:08:21 +00:00
2022-02-04 19:48:06 +00:00
var curcol = col ( '.' )
var w : string
var a : string
[w , a ] = spellbadword ( )
if col ( '.' ) > curcol # don 't use word after the cursor
w = ''
2005-07-21 21:08:21 +00:00
endif
if w ! = ''
2006-04-17 22:14:47 +00:00
if a = = 'caps'
2022-02-04 19:48:06 +00:00
s :suglist = [substitute ( w , '.*' , '\u&' , '' ) ]
2006-04-17 22:14:47 +00:00
else
2022-02-04 19:48:06 +00:00
s :suglist = spellsuggest ( w , 10 )
2006-04-17 22:14:47 +00:00
endif
2010-07-10 16:36:59 +02:00
if len ( s :suglist ) > 0
2018-05-17 13:15:23 +02:00
if ! exists ( "g:menutrans_spell_change_ARG_to" )
2022-02-04 19:48:06 +00:00
g :menutrans_spell_change_ARG_to = 'Change\ "%s"\ to'
2018-05-17 13:15:23 +02:00
endif
2022-02-04 19:48:06 +00:00
s :changeitem = printf ( g :menutrans_spell_change_ARG_to , escape ( w , ' .' ) )
s :fromword = w
var pri = 1
2005-07-21 21:08:21 +00:00
for sug in s :suglist
2022-02-04 19:48:06 +00:00
exe 'anoremenu 1.5.' .. pri .. ' PopUp.' .. s :changeitem .. '.' .. escape ( sug , ' .' )
\ .. ' :call <SID>SpellReplace(' .. pri .. ')<CR>'
pri + = 1
2005-07-21 21:08:21 +00:00
endfor
2018-05-17 13:15:23 +02:00
if ! exists ( "g:menutrans_spell_add_ARG_to_word_list" )
2022-02-04 19:48:06 +00:00
g :menutrans_spell_add_ARG_to_word_list = 'Add\ "%s"\ to\ Word\ List'
2018-05-17 13:15:23 +02:00
endif
2022-02-04 19:48:06 +00:00
s :additem = printf ( g :menutrans_spell_add_ARG_to_word_list , escape ( w , ' .' ) )
exe 'anoremenu 1.6 PopUp.' .. s :additem .. ' :spellgood ' .. w .. '<CR>'
2005-07-21 21:08:21 +00:00
2018-05-17 13:15:23 +02:00
if ! exists ( "g:menutrans_spell_ignore_ARG" )
2022-02-04 19:48:06 +00:00
g :menutrans_spell_ignore_ARG = 'Ignore\ "%s"'
2018-05-17 13:15:23 +02:00
endif
2022-02-04 19:48:06 +00:00
s :ignoreitem = printf ( g :menutrans_spell_ignore_ARG , escape ( w , ' .' ) )
exe 'anoremenu 1.7 PopUp.' .. s :ignoreitem .. ' :spellgood! ' .. w .. '<CR>'
2005-07-21 21:08:21 +00:00
2006-09-14 11:35:25 +00:00
anoremenu 1 .8 PopUp .- SpellSep - :
2005-07-21 21:08:21 +00:00
endif
endif
2022-02-04 19:48:06 +00:00
call cursor ( 0 , curcol ) # put the cursor back where it was
enddef
2005-07-21 21:08:21 +00:00
2022-02-04 19:48:06 +00:00
def s :SpellReplace ( n : number )
var l = getline ( '.' )
# Move the cursor to the start of the word .
2010-07-10 16:36:59 +02:00
call spellbadword ( )
2022-02-04 19:48:06 +00:00
call setline ( '.' , strpart ( l , 0 , col ( '.' ) - 1 ) .. s :suglist [n - 1 ]
\ .. strpart ( l , col ( '.' ) + len ( s :fromword ) - 1 ) )
enddef
def s :SpellDel ( )
exe "aunmenu PopUp." .. s :changeitem
exe "aunmenu PopUp." .. s :additem
exe "aunmenu PopUp." .. s :ignoreitem
2005-07-21 21:08:21 +00:00
aunmenu PopUp .- SpellSep -
2022-02-04 19:48:06 +00:00
s :changeitem = ''
enddef
2005-07-21 21:08:21 +00:00
2006-09-14 11:35:25 +00:00
augroup SpellPopupMenu
au ! MenuPopup * call < SID > SpellPopup ( )
augroup END
2005-07-21 21:08:21 +00:00
endif
2004-06-13 20:20:40 +00:00
" The GUI toolbar (for MS-Windows and GTK)
if has ( "toolbar" )
an 1 .10 ToolBar .Open :browse confirm e < CR >
an < silent > 1 .20 ToolBar .Save :if expand ( "%" ) = = "" < Bar > browse confirm w < Bar > else < Bar > confirm w < Bar > endif < CR >
an 1 .30 ToolBar .SaveAll :browse confirm wa < CR >
if has ( "printer" )
an 1 .40 ToolBar .Print :hardcopy < CR >
vunmenu ToolBar .Print
vnoremenu ToolBar .Print :hardcopy < CR >
elseif has ( "unix" )
an 1 .40 ToolBar .Print :w ! lpr < CR >
vunmenu ToolBar .Print
vnoremenu ToolBar .Print :w ! lpr < CR >
endif
an 1 .45 ToolBar .- sep1 - < Nop >
an 1 .50 ToolBar .Undo u
an 1 .60 ToolBar .Redo < C - R >
an 1 .65 ToolBar .- sep2 - < Nop >
vnoremenu 1 .70 ToolBar .Cut "+x
vnoremenu 1 .80 ToolBar .Copy "+y
cnoremenu 1 .80 ToolBar .Copy < C - Y >
nnoremenu 1 .90 ToolBar .Paste "+gP
cnoremenu ToolBar .Paste < C - R > +
2022-02-04 19:48:06 +00:00
exe 'vnoremenu <script> ToolBar.Paste ' .. paste #paste_cmd ['v' ]
exe 'inoremenu <script> ToolBar.Paste ' .. paste #paste_cmd ['i' ]
2004-06-13 20:20:40 +00:00
if ! has ( "gui_athena" )
an 1 .95 ToolBar .- sep3 - < Nop >
2005-03-15 22:43:58 +00:00
an 1 .100 ToolBar .Replace :promptrepl < CR >
2004-06-13 20:20:40 +00:00
vunmenu ToolBar .Replace
2006-03-09 22:32:39 +00:00
vnoremenu ToolBar .Replace y :promptrepl < C - R > = < SID > FixFText ( ) < CR > < CR >
2005-03-15 22:43:58 +00:00
an 1 .110 ToolBar .FindNext n
an 1 .120 ToolBar .FindPrev N
2004-06-13 20:20:40 +00:00
endif
an 1 .215 ToolBar .- sep5 - < Nop >
an < silent > 1 .220 ToolBar .LoadSesn :call < SID > LoadVimSesn ( ) < CR >
an < silent > 1 .230 ToolBar .SaveSesn :call < SID > SaveVimSesn ( ) < CR >
an 1 .240 ToolBar .RunScript :browse so < CR >
an 1 .245 ToolBar .- sep6 - < Nop >
an 1 .250 ToolBar .Make :make < CR >
2022-02-04 19:48:06 +00:00
an 1 .270 ToolBar .RunCtags :exe "!" .. g :ctags_command < CR >
2004-06-13 20:20:40 +00:00
an 1 .280 ToolBar .TagJump g < C - ]>
an 1 .295 ToolBar .- sep7 - < Nop >
an 1 .300 ToolBar .Help :help < CR >
an < silent > 1 .310 ToolBar .FindHelp :call < SID > Helpfind ( ) < CR >
" Only set the tooltips here if not done in a language menu file
if exists ( "*Do_toolbar_tmenu" )
call Do_toolbar_tmenu ( )
else
let did_toolbar_tmenu = 1
tmenu ToolBar .Open Open file
tmenu ToolBar .Save Save current file
tmenu ToolBar .SaveAll Save all files
tmenu ToolBar .Print Print
tmenu ToolBar .Undo Undo
tmenu ToolBar .Redo Redo
tmenu ToolBar .Cut Cut to clipboard
tmenu ToolBar .Copy Copy to clipboard
tmenu ToolBar .Paste Paste from Clipboard
if ! has ( "gui_athena" )
2010-01-06 20:54:52 +01:00
tmenu ToolBar .Replace Find / Replace ...
2004-06-13 20:20:40 +00:00
tmenu ToolBar .FindNext Find Next
tmenu ToolBar .FindPrev Find Previous
endif
2006-09-14 11:35:25 +00:00
tmenu ToolBar .LoadSesn Choose a session to load
2004-06-13 20:20:40 +00:00
tmenu ToolBar .SaveSesn Save current session
2024-10-13 19:16:42 +02:00
tmenu ToolBar .RunScript Choose a Vim script to run
2005-03-15 22:43:58 +00:00
tmenu ToolBar .Make Make current project ( :make )
tmenu ToolBar .RunCtags Build tags in current directory tree ( ! ctags - R .)
2004-06-13 20:20:40 +00:00
tmenu ToolBar .TagJump Jump to tag under cursor
tmenu ToolBar .Help Vim Help
tmenu ToolBar .FindHelp Search Vim Help
endif
" Select a session to load; default to current session name if present
2022-02-04 19:48:06 +00:00
def s :LoadVimSesn ( )
var name : string
2004-06-13 20:20:40 +00:00
if strlen ( v :this_session ) > 0
2022-02-04 19:48:06 +00:00
name = fnameescape ( v :this_session )
2004-06-13 20:20:40 +00:00
else
2022-02-04 19:48:06 +00:00
name = "Session.vim"
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
execute "browse so " .. name
enddef
2004-06-13 20:20:40 +00:00
" Select a session to save; default to current session name if present
2022-02-04 19:48:06 +00:00
def s :SaveVimSesn ( )
2004-06-13 20:20:40 +00:00
if strlen ( v :this_session ) = = 0
2022-02-04 19:48:06 +00:00
v :this_session = "Session.vim"
2004-06-13 20:20:40 +00:00
endif
2022-02-04 19:48:06 +00:00
execute "browse mksession! " .. fnameescape ( v :this_session )
enddef
2004-06-13 20:20:40 +00:00
endif
endif " !exists(" did_install_default_menus ")
" Define these items always, so that syntax can be switched on when it wasn't.
" But skip them when the Syntax menu was disabled by the user.
if ! exists ( "did_install_syntax_menu" )
an 50 .212 &Syntax .&Manual :syn manual < CR >
an 50 .214 &Syntax .A &utomatic :syn on < CR >
2017-03-05 17:04:09 +01:00
an < silent > 50 .216 &Syntax .On /Off \ for \ &This \ File :call < SID > SynOnOff ( ) < CR >
2004-06-13 20:20:40 +00:00
if ! exists ( "*s:SynOnOff" )
2022-02-04 19:48:06 +00:00
def s :SynOnOff ( )
2004-06-13 20:20:40 +00:00
if has ( "syntax_items" )
syn clear
else
if ! exists ( "g:syntax_on" )
syn manual
endif
set syn = ON
endif
2022-02-04 19:48:06 +00:00
enddef
2004-06-13 20:20:40 +00:00
endif
endif
" Install the Syntax menu only when filetype.vim has been loaded or when
" manual syntax highlighting is enabled.
" Avoid installing the Syntax menu twice.
if ( exists ( "did_load_filetypes" ) | | exists ( "syntax_on" ) )
\ && ! exists ( "did_install_syntax_menu" )
let did_install_syntax_menu = 1
" Skip setting up the individual syntax selection menus unless
" do_syntax_sel_menu is defined (it takes quite a bit of time).
if exists ( "do_syntax_sel_menu" )
runtime ! synmenu .vim
else
2017-11-09 19:45:48 +01:00
an < silent > 50 .10 &Syntax .&Show \ File \ Types \ in \ Menu :let do_syntax_sel_menu = 1 < Bar > runtime ! synmenu .vim < Bar > aunmenu &Syntax .&Show \ File \ Types \ in \ Menu < CR >
2004-06-13 20:20:40 +00:00
an 50 .195 &Syntax .- SEP1 - < Nop >
endif
an 50 .210 &Syntax .&Off :syn off < CR >
an 50 .700 &Syntax .- SEP3 - < Nop >
2017-03-05 17:04:09 +01:00
an 50 .710 &Syntax .Co &lor \ Test :sp $VIMRUNTIME /syntax/ colortest .vim < Bar > so %< CR >
an 50 .720 &Syntax .&Highlight \ Test :runtime syntax /hitest .vim < CR >
2004-06-13 20:20:40 +00:00
an 50 .730 &Syntax .&Convert \ to \ HTML :runtime syntax /2 html.vim < CR >
2022-02-09 21:50:44 +00:00
" Uncomment the next line to compile the functions early to find any mistakes
" defcompile
2022-02-04 19:48:06 +00:00
2004-06-13 20:20:40 +00:00
endif " !exists(" did_install_syntax_menu ")
" Restore the previous value of 'cpoptions'.
let &cpo = s :cpo_save
unlet s :cpo_save
" vim: set sw=2 :