vim - Does the order of the sections of code in my _vimrc matter? -
how sections of code in _vimrc
file interact each other?
current file looks following i'm wondering if matters if line such filetype plugin indent on
@ start or end of file?
matter if line filetype plugin indent on
repeated twice in file?
should pathogen
settings near start?
"------------------------------------------------------------ " must have options {{{1 "this make window maximized on startup au guienter * simalt ~x " attempt determine type of file based on name , possibly " contents. use allow intelligent auto-indenting each filetype, " , plugins filetype specific. filetype indent plugin on set omnifunc=syntaxcomplete#complete " enable syntax highlighting syntax on "set highlight search on :set hlsearch "------------------------------------------------------------ " usability options {{{1 " show partial commands in last line of screen set showcmd " use case insensitive search, except when using capital letters set ignorecase set smartcase " allow backspacing on autoindent, line breaks , start of insert action set backspace=indent,eol,start " when opening new line , no filetype-specific indenting enabled, keep " same indent line you're on. useful readmes, etc. set autoindent " stop movements going first character of line. " while behaviour deviates of vi, users " coming other editors expect. set nostartofline " display cursor position on last line of screen or in status " line of window set ruler " display status line, if 1 window displayed set laststatus=2 " instead of failing command because of unsaved changes, instead raise " dialogue asking if wish save changed files. set confirm " use visual bell instead of beeping when doing wrong set visualbell " , reset terminal code visual bell. if visualbell set, , " line included, vim neither flash nor beep. if visualbell " unset, nothing. set t_vb= " enable use of mouse modes set mouse=a " set command window height 2 lines, avoid many cases of having " "press <enter> continue" set cmdheight=2 " display line numbers on left set number " time out on keycodes, never time out on mappings set notimeout ttimeout ttimeoutlen=200 " use <f11> toggle between 'paste' , 'nopaste' set pastetoggle=<f11> "------------------------------------------------------------ " indentation options {{{1 " " indentation settings according personal preference. " indentation settings using 2 spaces instead of tabs. " not change 'tabstop' default value of 8 setup. "set shiftwidth=2 "set softtabstop=2 "set expandtab " indentation settings using hard tabs indent. display tabs " 2 characters wide. set shiftwidth=2 set tabstop=2 "------------------------------------------------------------ " , feel {{{1 " " use ctrl-s saving, in insert mode :nnoremap <c-s> :<c-u>update<cr> :vnoremap <c-s> :<c-u>update<cr>gv :cnoremap <c-s> <c-c>:update<cr> :inoremap <c-s> <c-o>:update<cr> "color scheme setting " set nice colors " background normal text light grey " text below last line darker grey " cursor green, cyan when ":lmap" mappings active " constants not underlined have lighter background set guifont=consolas:h16:cansi colorscheme pyte "highlight normal guibg=grey90 "highlight cursor guibg=green guifg=none "highlight lcursor guibg=cyan guifg=none "highlight nontext guibg=grey80 "highlight constant gui=none guibg=grey95 "highlight special gui=none guibg=grey95 "a quick way locate python files nnoremap <leader>p :pyf p:\computer applications\python\ "quick quit command noremap <leader>e :quit<cr> "quits current window "------------------------------------------------------------ " nerttree settings {{{1 " "get nerdtree command quick nnoremap <leader>nd :nerdtree m:\ map <f2> :nerdtreetoggle<cr> let nerdtreequitonopen = 1 " rebind <leader> key...not sure 1 "let mapleader = "," map <leader>n <esc>:tabprevious<cr> map <leader>m <esc>:tabnext<cr> "------------------------------------------------------------ " dbext settings {{{1 " "let g:sql_type_default = 'sqlsvr' " since repeatedly need edit stored procedures, create procedure " statement preceeded if ... end if block drop " procedure or uses create or replace syntax. " function visually select if block end; statement " of stored procedure , execute it. or check " create or replace , stop there , end. function! sqlexecuteifcreatereplace() let l:old_sel = &sel let &sel = 'inclusive' let savewrapscan=&wrapscan let savesearch=@/ let l:reg_z = @z let &wrapscan=0 let @z = '' let found = 0 let startline = 0 let endline = 0 let curline = line(".") let curcol = virtcol(".") " must default command terminator let l:dbext_cmd_terminator = ";" try " search backwards , not wrap " find line beginning if clause " if exists( select 1 ... " or find or replace clause " create or replace procedure ... " , execute until find " end " @ beginning of line. let startline = search('\c\(^\<if\>\|^\<alter\s\+procedure\>\|\<or\s\+replace\>\)', 'bcnw' ) if startline > 0 " search forward , visually select lines " until find end; clause let endline = search('^end'.l:dbext_cmd_terminator.'\s*$', 'cnw') exec startline.','.endline.'dbexecrangesql' endif call cursor(curline, curcol) noh let l:query = @z let @z = l:reg_z let @/=savesearch let &wrapscan=savewrapscan let &sel = l:old_sel endtry endfunction "------------------------------------------------------------ " pathogen settings {{{1 "pathogen customization "set nocp " use pathogen modify runtime path include plugins under " ~/.vim/bundle directory filetype off " force reloading *after* pathogen loaded call pathogen#infect() call pathogen#helptags() call pathogen#runtime_append_all_bundles() syntax on filetype plugin indent on " enable detection, plugins , indenting in 1 step
tl;dr: do, don't; use logical structure simple complex.
pathogen wants settings appear @ top, because modifies way other scripts loaded (explicitly via :runtime
, or side effect of calling autoload functions).
the order of :set
doesn't matter (unless have conflicting settings), , mappings or autocmds define activated after startup, can put them anywhere.
in general, i'd recommend logical structure, starting basic stuff pathogen, settings, plugin configuration, followed custom mappings , more involved adaptations autocmds.
also, i'd avoid putting filetype-specific stuff ~/.vimrc
; rather, put corresponding ~/.vim/after/ftplugin/<filetype>.vim
script , use filetype plugin on
.
Comments
Post a Comment