Skip to content

Instantly share code, notes, and snippets.

@agail
Last active December 16, 2020 13:44
Show Gist options
  • Save agail/eaf7125e3fa21d7b146e8e9f85548e08 to your computer and use it in GitHub Desktop.
Save agail/eaf7125e3fa21d7b146e8e9f85548e08 to your computer and use it in GitHub Desktop.
Vim settings
" Automatically switch into paste mode when pasting text
let &t_SI .= "\<Esc>[?2004h"
let &t_EI .= "\<Esc>[?2004l"
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()
function! XTermPasteBegin()
set pastetoggle=<Esc>[201~
set paste
return ""
endfunction
" Manually toggle paste while in insert mode
set pastetoggle=<F2>
" https://stackoverflow.com/questions/1878974/redefine-tab-as-4-spaces
" For tab characters that appear 4-spaces-wide:
" set tabstop=4
" If you're using actual tab character in your source code you probably also want these settings
" (these are actually the defaults, but you may want to set them defensively):
" set softtabstop=0 noexpandtab
" Finally, if you want an indent to correspond to a single tab, you should also use:
" set shiftwidth=4
" For indents that consist of 4 space characters but are entered with the tab key:
" set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab
" To make the above settings permanent add these lines to your vimrc.
" In case you need to make adjustments, or would simply like to understand what these options all mean,
" here's a breakdown of what each option means:
" tabstop
" The width of a hard tabstop measured in "spaces" -- effectively the (maximum) width of an actual tab character.
" shiftwidth
" The size of an "indent". It's also measured in spaces, so if your code base indents with tab characters then you want
" shiftwidth to equal the number of tab characters times tabstop. This is also used by things like the =, > and < commands.
" softtabstop
" Setting this to a non-zero value other than tabstop will make the tab key (in insert mode) insert a combination of spaces
" (and possibly tabs) to simulate tab stops at this width.
" expandtab
" Enabling this will make the tab key (in insert mode) insert spaces instead of tab characters. This also affects the behavior
" of the retab command.
" smarttab
" Enabling this will make the tab key (in insert mode) insert spaces or tabs to go to the next indent of the next tabstop when
" the cursor is at the beginning of a line (i.e. the only preceding characters are whitespace).
" For more details on any of these see :help 'optionname' in vim (e.g. :help 'tabstop')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment