Last active
September 16, 2016 08:59
-
-
Save robbintt/ab3aa158a0d6cb574074 to your computer and use it in GitHub Desktop.
Toggle tab size in .vimrc with <f3>. If you start in some other mode, you'll probably want to set the customtabsize state of your TabToggle() function to that mode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Apparently some vim environments require colons before commands in | |
" .vimrc and others don't. This file has been primarily tested in | |
" Ubuntu 12.04, 13.10, and 14.04 environments, where a : is required | |
" on each line before a command. According to one stackexchange topic | |
" it is best to leave the leading colons because systems that do not | |
" require them can still execute them. | |
" Author - Trent Robbins | |
" Turn arrow keys off: | |
" To cycle history in `ed` mode, use C-n and C-p (although up and down might work fine) | |
inoremap <Up> <NOP> | |
inoremap <Down> <NOP> | |
inoremap <Left> <NOP> | |
inoremap <Right> <NOP> | |
noremap <Up> <NOP> | |
noremap <Down> <NOP> | |
noremap <Left> <NOP> | |
noremap <Right> <NOP> | |
:set background=dark | |
:set scrolloff=5 | |
" set backspace for mac delete key (otherwise it doesn't work) | |
" :set backspace=indent,eol,start | |
" syntax by default | |
:syntax enable | |
" inserts spaces instead of a tab | |
:set expandtab | |
"maintain tabbing increments when backspacing tabs (speed things up) | |
:set smarttab | |
"show the commands which you enter in the bottom right corner | |
:set showcmd | |
" set spaces used for indentenation | |
:set shiftwidth=4 | |
:set tabstop=4 | |
" does a tabstop of 4 during edit commands | |
:set softtabstop=4 | |
" Turn on line numbers: | |
:set number | |
" indent to previous line automatically | |
:filetype plugin indent on | |
" allow input toggle to paste mode with F2 | |
:set pastetoggle=<F2> | |
" customtabsize's state informs the function what state you are currently in | |
" if the default settings change, then this variable would need to be changed too | |
" try this... :let customtabsize = 0 | |
:let g:customtabsize=1 | |
" allow toggle between 2/4 spaces. | |
function TabToggle() | |
if g:customtabsize | |
:set shiftwidth=2 | |
:set tabstop=2 | |
:set softtabstop=2 | |
:let g:customtabsize=0 | |
else | |
:set shiftwidth=4 | |
:set tabstop=4 | |
:set softtabstop=4 | |
:let g:customtabsize=1 | |
endif | |
endfunction | |
" TabToggle dumps you at the top of the document so you need to mark your | |
" place... set scrolloff=5 or higher to have a better time finding the cursor | |
:nmap <F3> mz:execute TabToggle()<cr>'z | |
" Quickly quit without saving with QQ | |
:nmap QQ :q!<cr> | |
" Maintain undo history between sessions | |
:set undofile | |
:set undodir=~/.vim | |
:set undolevels=1000 " This many undos are saved. | |
:set undoreload=10000 " This saves 10000 lines of undos, which is the default | |
:set foldmethod=indent | |
:set foldlevel=99 | |
:nnoremap <Space> za | |
" Keep visual block after changing indent | |
:vmap > >gv | |
:vmap < <gv | |
" Highlight things that we find with the search | |
:set hlsearch | |
" <Ctrl-l> redraws the screen and removes any search highlighting. | |
:nnoremap <silent> <C-l> :nohl<CR><C-l> | |
" Allow .MD files to automagically use markdown syntax | |
:au BufNewFile,BufReadPost *.MD set filetype=markdown | |
:au BufRead,BufNewFile *.md set filetype=markdown | |
" Set Cursor row and column colors | |
:highlight CursorLine ctermbg=Black cterm=NONE | |
:highlight CursorColumn ctermbg=Black cterm=NONE | |
" :highlight CursorColumn ctermbg=LightMagenta cterm=NONE | |
" Set Cursor row and column to on. | |
augroup CursorLine | |
au! | |
au VimEnter,WinEnter,BufWinEnter * setlocal cursorline cursorcolumn | |
au WinLeave * setlocal nocursorline nocursorcolumn | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment