From 07d5852f1b8b3479aca1169df90137be54ed5fb2 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 8 Jul 2018 15:59:42 +1200 Subject: Use :setglobal and :setlocal in .vimrc So that if the file gets reloaded, stuff in filetype buffers doesn't get its settings messed with. --- vim/vimrc | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'vim/vimrc') diff --git a/vim/vimrc b/vim/vimrc index 06ebb4f7..f8d5a80e 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -32,15 +32,15 @@ if has('syntax') && !exists('g:syntax_on') endif " The all-important default indent settings; filetypes to tweak -set autoindent " Use indent of previous line on new lines -set expandtab " Use spaces instead of tabs -set shiftwidth=4 " Indent with four spaces +setglobal autoindent " Use indent of previous line on new lines +setglobal expandtab " Use spaces instead of tabs +setglobal shiftwidth=4 " Indent with four spaces " Spaces to insert on Tab key insert if v:version > 703 || v:version == 703 && has('patch693') - set softtabstop=-1 " Refer to 'shiftwidth' if supported + setglobal softtabstop=-1 " Refer to 'shiftwidth' if supported else - set softtabstop=4 " Otherwise just four spaces + setglobal softtabstop=4 " Otherwise just four spaces endif " Let me backspace over pretty much anything @@ -69,14 +69,14 @@ endif " Delete comment leaders when joining lines, if supported if v:version > 703 || v:version == 703 && has('patch541') - set formatoptions+=j + setglobal formatoptions+=j endif " Keep more command and search history set history=500 " Don't assume I'm editing C; let the filetype set this -set include= +setglobal include= " Don't join lines with two spaces at the end of sentences set nojoinspaces @@ -99,13 +99,13 @@ if v:version >= 700 endif " Add angle brackets to pairs of matched characters -set matchpairs+=<:> +setglobal matchpairs+=<:> " Don't allow setting options via buffer content -set nomodeline +setglobal nomodeline " Treat numbers with a leading zero as decimal, not octal -set nrformats-=octal +setglobal nrformats-=octal " Abbreviate some more regularly displayed messages set shortmess+=I " Don't show startup splash screen @@ -115,7 +115,7 @@ set shortmess+=w " written -> [w], appended -> [a] " Clear default 'comments' value, let the filetype handle it if has('comments') - set comments= + setglobal comments= endif " Highlight settings for search @@ -127,7 +127,7 @@ endif " More sensible language-agnostic setting for gf/:find if has('file_in_path') - set path=.,,** + setglobal path=.,,** endif " Don't load GUI menus; set here before GUI starts @@ -137,10 +137,10 @@ endif " Line break behaviour settings for 'wrap' if has('linebreak') - set linebreak " Break lines at word boundaries - set showbreak=... " Prefix wrapped rows with three dots + setglobal linebreak " Break lines at word boundaries + set showbreak=... " Prefix wrapped rows with three dots if exists('+breakindent') - set breakindent " Indent wrapped lines, if supported + setglobal breakindent " Indent wrapped lines, if supported endif endif @@ -222,17 +222,17 @@ nnoremap a :ToggleOptionFlagLocal formatoptions a " \b toggles copy-pasteable linebreak settings nmap b CopyLinebreakToggle " \c toggles 'cursorline' -nnoremap c :set cursorline! cursorline? +nnoremap c :setlocal cursorline! cursorline? " \C toggles 'cursorcolumn' -nnoremap C :set cursorcolumn! cursorcolumn? +nnoremap C :setlocal cursorcolumn! cursorcolumn? " \d inserts the local date (POSIX date) nnoremap d :read !date " \D inserts the UTC date (POSIX date) nnoremap D :read !date -u " \e forces a buffer to be editable -nnoremap e :set modifiable noreadonly +nnoremap e :setlocal modifiable noreadonly " \f shows the current 'formatoptions' at a glance -nnoremap f :set formatoptions? +nnoremap f :setlocal formatoptions? " \g changes directory to the current file's location nnoremap g :cd %:h:pwd " \h toggles highlighting search results @@ -244,13 +244,13 @@ nnoremap j :buffers:buffer " \k shows my marks nnoremap k :marks " \l toggles showing tab, end-of-line, and trailing whitespace -nnoremap l :set list! list? +nnoremap l :setlocal list! list? " \m shows all maps nnoremap m :map " \M shows buffer-local maps nnoremap M :map " \n toggles line numbers -nnoremap n :set number! number? +nnoremap n :setlocal number! number? " \N toggles 'ruler' nnoremap N :set ruler! ruler? " \o opens a line below in paste mode @@ -266,7 +266,7 @@ nnoremap r :source $MYVIMRC " \s toggles spell checking nnoremap s :setlocal spell! spell? " \t shows current filetype -nnoremap t :set filetype? +nnoremap t :setlocal filetype? " \u sets US English spelling (compare \z) nnoremap u :setlocal spelllang=en_us " \v shows all global variables @@ -274,7 +274,7 @@ nnoremap v :let g: v: " \V shows all local variables nnoremap V :let b: t: w: " \w toggles wrapping -nnoremap w :set wrap! wrap? +nnoremap w :setlocal wrap! wrap? " \x strips trailing whitespace via a custom plugin nmap x StripTrailingWhitespace " \y shows all registers -- cgit v1.2.3