2016-07-28 22:24:15 +02:00
|
|
|
" The default vimrc file.
|
|
|
|
"
|
2023-08-13 10:33:05 +02:00
|
|
|
" Maintainer: The Vim Project <https://github.com/vim/vim>
|
2024-12-01 16:25:53 +01:00
|
|
|
" Last Change: 2024 Dec 01
|
2023-08-13 10:33:05 +02:00
|
|
|
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
|
2016-07-28 22:24:15 +02:00
|
|
|
"
|
|
|
|
" This is loaded if no vimrc file was found.
|
|
|
|
" Except when Vim is run with "-u NONE" or "-C".
|
|
|
|
" Individual settings can be reverted with ":set option&".
|
|
|
|
" Other commands can be reverted as mentioned below.
|
|
|
|
|
|
|
|
" When started as "evim", evim.vim will already have done these settings.
|
|
|
|
if v:progname =~? "evim"
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
2016-09-03 20:08:56 +02:00
|
|
|
" Bail out if something that ran earlier, e.g. a system wide vimrc, does not
|
|
|
|
" want Vim to use these default values.
|
|
|
|
if exists('skip_defaults_vim')
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
2016-07-28 22:24:15 +02:00
|
|
|
" Use Vim settings, rather than Vi settings (much better!).
|
|
|
|
" This must be first, because it changes other options as a side effect.
|
2017-03-16 14:19:36 +01:00
|
|
|
" Avoid side effects when it was already reset.
|
|
|
|
if &compatible
|
|
|
|
set nocompatible
|
|
|
|
endif
|
2016-07-28 22:24:15 +02:00
|
|
|
|
2017-04-01 16:59:29 +02:00
|
|
|
" When the +eval feature is missing, the set command above will be skipped.
|
|
|
|
" Use a trick to reset compatible only when the +eval feature is missing.
|
2017-04-15 15:37:25 +02:00
|
|
|
silent! while 0
|
|
|
|
set nocompatible
|
|
|
|
silent! endwhile
|
2017-04-01 16:59:29 +02:00
|
|
|
|
2016-07-28 22:24:15 +02:00
|
|
|
set ruler " show the cursor position all the time
|
|
|
|
set showcmd " display incomplete commands
|
|
|
|
|
2016-08-20 19:22:16 +02:00
|
|
|
set ttimeout " time out for key codes
|
|
|
|
set ttimeoutlen=100 " wait up to 100ms after Esc for special key
|
|
|
|
|
2016-07-29 18:13:42 +02:00
|
|
|
" Show @@@ in the last line if it is truncated.
|
|
|
|
set display=truncate
|
|
|
|
|
2016-08-30 23:26:57 +02:00
|
|
|
" Show a few lines of context around the cursor. Note that this makes the
|
|
|
|
" text scroll if you mouse-click near the start or end of the window.
|
2016-08-28 14:39:44 +02:00
|
|
|
set scrolloff=5
|
|
|
|
|
2016-07-28 22:24:15 +02:00
|
|
|
" Do incremental searching when it's possible to timeout.
|
|
|
|
if has('reltime')
|
|
|
|
set incsearch
|
|
|
|
endif
|
|
|
|
|
|
|
|
" Do not recognize octal numbers for Ctrl-A and Ctrl-X, most users find it
|
|
|
|
" confusing.
|
|
|
|
set nrformats-=octal
|
|
|
|
|
|
|
|
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries.
|
|
|
|
if has('win32')
|
|
|
|
set guioptions-=t
|
|
|
|
endif
|
|
|
|
|
2022-03-08 21:35:07 +00:00
|
|
|
" Don't use Q for Ex mode, use it for formatting. Except for Select mode.
|
2016-07-28 22:24:15 +02:00
|
|
|
" Revert with ":unmap Q".
|
|
|
|
map Q gq
|
2022-03-08 21:35:07 +00:00
|
|
|
sunmap Q
|
2016-07-28 22:24:15 +02:00
|
|
|
|
|
|
|
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
|
|
|
|
" so that you can undo CTRL-U after inserting a line break.
|
|
|
|
" Revert with ":iunmap <C-U>".
|
|
|
|
inoremap <C-U> <C-G>u<C-U>
|
|
|
|
|
|
|
|
" In many terminal emulators the mouse works just fine. By enabling it you
|
|
|
|
" can position the cursor, Visually select and scroll with the mouse.
|
2019-10-27 18:50:25 +01:00
|
|
|
" Only xterm can grab the mouse events when using the shift key, for other
|
|
|
|
" terminals use ":", select text and press Esc.
|
2016-07-28 22:24:15 +02:00
|
|
|
if has('mouse')
|
2019-10-27 18:50:25 +01:00
|
|
|
if &term =~ 'xterm'
|
|
|
|
set mouse=a
|
|
|
|
else
|
|
|
|
set mouse=nvi
|
|
|
|
endif
|
2016-07-28 22:24:15 +02:00
|
|
|
endif
|
|
|
|
|
2019-02-18 21:32:28 +01:00
|
|
|
" Only do this part when Vim was compiled with the +eval feature.
|
|
|
|
if 1
|
|
|
|
|
|
|
|
" Enable file type detection.
|
|
|
|
" Use the default filetype settings, so that mail gets 'tw' set to 72,
|
|
|
|
" 'cindent' is on in C files, etc.
|
|
|
|
" Also load indent files, to automatically do language-dependent indenting.
|
|
|
|
" Revert with ":filetype off".
|
|
|
|
filetype plugin indent on
|
|
|
|
|
|
|
|
" Put these in an autocmd group, so that you can revert them with:
|
2023-07-14 16:59:40 +00:00
|
|
|
" ":autocmd! vimStartup"
|
2019-02-18 21:32:28 +01:00
|
|
|
augroup vimStartup
|
Update the vimscript code for restoring cursor position
Using xxd(1) to filter and edit binary files causes the input files
to have dual nature, so to speak, which effectively makes restoring
the cursor position broken. Fix that by ignoring the "xxd" file type
in the code that restores the cursor position.
Interactive rebasing in git causes files to be edited in vim, which,
similarly to commit messages, are rarely the same as the last one
edited. Thus, also add "gitrebase" to the list of file types for
which the cursor position isn't restored.
While there, refactor the code a bit to possibly save a few CPU cycles
and to keep the line lengths in check, and use the long form of the
commands and variables, to make the code slightly more consistent and
more understandable to newcomers.
Update the relevant comments in the code and the associated parts of
the documentation, to keep them in sync with the updated code.
Remove some redundant trailing whitespace as well, as spotted.
2023-08-09 17:23:58 +02:00
|
|
|
autocmd!
|
2019-02-18 21:32:28 +01:00
|
|
|
|
|
|
|
" When editing a file, always jump to the last known cursor position.
|
|
|
|
" Don't do it when the position is invalid, when inside an event handler
|
Update the vimscript code for restoring cursor position
Using xxd(1) to filter and edit binary files causes the input files
to have dual nature, so to speak, which effectively makes restoring
the cursor position broken. Fix that by ignoring the "xxd" file type
in the code that restores the cursor position.
Interactive rebasing in git causes files to be edited in vim, which,
similarly to commit messages, are rarely the same as the last one
edited. Thus, also add "gitrebase" to the list of file types for
which the cursor position isn't restored.
While there, refactor the code a bit to possibly save a few CPU cycles
and to keep the line lengths in check, and use the long form of the
commands and variables, to make the code slightly more consistent and
more understandable to newcomers.
Update the relevant comments in the code and the associated parts of
the documentation, to keep them in sync with the updated code.
Remove some redundant trailing whitespace as well, as spotted.
2023-08-09 17:23:58 +02:00
|
|
|
" (happens when dropping a file on gvim), for a commit or rebase message
|
|
|
|
" (likely a different one than last time), and when using xxd(1) to filter
|
|
|
|
" and edit binary files (it transforms input files back and forth, causing
|
2024-11-03 10:49:23 +01:00
|
|
|
" them to have dual nature, so to speak) or when running the new tutor
|
2019-02-18 21:32:28 +01:00
|
|
|
autocmd BufReadPost *
|
Update the vimscript code for restoring cursor position
Using xxd(1) to filter and edit binary files causes the input files
to have dual nature, so to speak, which effectively makes restoring
the cursor position broken. Fix that by ignoring the "xxd" file type
in the code that restores the cursor position.
Interactive rebasing in git causes files to be edited in vim, which,
similarly to commit messages, are rarely the same as the last one
edited. Thus, also add "gitrebase" to the list of file types for
which the cursor position isn't restored.
While there, refactor the code a bit to possibly save a few CPU cycles
and to keep the line lengths in check, and use the long form of the
commands and variables, to make the code slightly more consistent and
more understandable to newcomers.
Update the relevant comments in the code and the associated parts of
the documentation, to keep them in sync with the updated code.
Remove some redundant trailing whitespace as well, as spotted.
2023-08-09 17:23:58 +02:00
|
|
|
\ let line = line("'\"")
|
|
|
|
\ | if line >= 1 && line <= line("$") && &filetype !~# 'commit'
|
2024-11-03 10:49:23 +01:00
|
|
|
\ && index(['xxd', 'gitrebase', 'tutor'], &filetype) == -1
|
Update the vimscript code for restoring cursor position
Using xxd(1) to filter and edit binary files causes the input files
to have dual nature, so to speak, which effectively makes restoring
the cursor position broken. Fix that by ignoring the "xxd" file type
in the code that restores the cursor position.
Interactive rebasing in git causes files to be edited in vim, which,
similarly to commit messages, are rarely the same as the last one
edited. Thus, also add "gitrebase" to the list of file types for
which the cursor position isn't restored.
While there, refactor the code a bit to possibly save a few CPU cycles
and to keep the line lengths in check, and use the long form of the
commands and variables, to make the code slightly more consistent and
more understandable to newcomers.
Update the relevant comments in the code and the associated parts of
the documentation, to keep them in sync with the updated code.
Remove some redundant trailing whitespace as well, as spotted.
2023-08-09 17:23:58 +02:00
|
|
|
\ | execute "normal! g`\""
|
2019-02-18 21:32:28 +01:00
|
|
|
\ | endif
|
|
|
|
|
2024-11-09 18:37:32 +01:00
|
|
|
" Set the default background for putty to dark. Putty usually sets the
|
2024-10-27 21:33:09 +01:00
|
|
|
" $TERM to xterm and by default it starts with a dark background which
|
|
|
|
" makes syntax highlighting often hard to read with bg=light
|
|
|
|
" undo this using: ":au! vimStartup TermResponse"
|
|
|
|
autocmd TermResponse * if v:termresponse == "\e[>0;136;0c" | set bg=dark | endif
|
2019-02-18 21:32:28 +01:00
|
|
|
augroup END
|
|
|
|
|
2021-11-17 14:01:14 +00:00
|
|
|
" Quite a few people accidentally type "q:" instead of ":q" and get confused
|
|
|
|
" by the command line window. Give a hint about how to get out.
|
|
|
|
" If you don't like this you can put this in your vimrc:
|
2023-07-14 16:59:40 +00:00
|
|
|
" ":autocmd! vimHints"
|
2021-11-17 14:01:14 +00:00
|
|
|
augroup vimHints
|
2021-11-21 21:13:36 +00:00
|
|
|
au!
|
|
|
|
autocmd CmdwinEnter *
|
Update the vimscript code for restoring cursor position
Using xxd(1) to filter and edit binary files causes the input files
to have dual nature, so to speak, which effectively makes restoring
the cursor position broken. Fix that by ignoring the "xxd" file type
in the code that restores the cursor position.
Interactive rebasing in git causes files to be edited in vim, which,
similarly to commit messages, are rarely the same as the last one
edited. Thus, also add "gitrebase" to the list of file types for
which the cursor position isn't restored.
While there, refactor the code a bit to possibly save a few CPU cycles
and to keep the line lengths in check, and use the long form of the
commands and variables, to make the code slightly more consistent and
more understandable to newcomers.
Update the relevant comments in the code and the associated parts of
the documentation, to keep them in sync with the updated code.
Remove some redundant trailing whitespace as well, as spotted.
2023-08-09 17:23:58 +02:00
|
|
|
\ echohl Todo |
|
2023-05-10 14:47:50 +01:00
|
|
|
\ echo gettext('You discovered the command-line window! You can close it with ":q".') |
|
2021-11-17 14:01:14 +00:00
|
|
|
\ echohl None
|
|
|
|
augroup END
|
|
|
|
|
2019-02-18 21:32:28 +01:00
|
|
|
endif
|
2016-07-28 22:24:15 +02:00
|
|
|
|
2020-09-30 22:45:39 +02:00
|
|
|
" Switch syntax highlighting on when the terminal has colors or when using the
|
|
|
|
" GUI (which always has colors).
|
|
|
|
if &t_Co > 2 || has("gui_running")
|
|
|
|
" Revert with ":syntax off".
|
|
|
|
syntax on
|
|
|
|
|
|
|
|
" I like highlighting strings inside C comments.
|
|
|
|
" Revert with ":unlet c_comment_strings".
|
|
|
|
let c_comment_strings=1
|
|
|
|
endif
|
|
|
|
|
2016-07-28 22:24:15 +02:00
|
|
|
" Convenient command to see the difference between the current buffer and the
|
|
|
|
" file it was loaded from, thus the changes you made.
|
|
|
|
" Only define it when not defined already.
|
|
|
|
" Revert with: ":delcommand DiffOrig".
|
|
|
|
if !exists(":DiffOrig")
|
|
|
|
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
|
|
|
|
\ | wincmd p | diffthis
|
|
|
|
endif
|
|
|
|
|
2016-08-21 17:45:02 +02:00
|
|
|
if has('langmap') && exists('+langremap')
|
2016-07-28 22:24:15 +02:00
|
|
|
" Prevent that the langmap option applies to characters that result from a
|
2016-08-21 17:45:02 +02:00
|
|
|
" mapping. If set (default), this may break plugins (but it's backward
|
2016-07-28 22:24:15 +02:00
|
|
|
" compatible).
|
2016-08-21 17:45:02 +02:00
|
|
|
set nolangremap
|
2016-07-28 22:24:15 +02:00
|
|
|
endif
|