Last active
November 12, 2023 18:55
-
-
Save martycagas/9ffefa582c0417649445cee600216e11 to your computer and use it in GitHub Desktop.
Personal .vimrc file for access via git or curl anywhere, based on the https://vim.wikia.com/wiki/Example_vimrc
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
" Personal .vimrc file, so far still heavily based one the | |
" URL: https://vim.wikia.com/wiki/Example_vimrc | |
" Set 'nocompatible' to ward off unexpected things that your distro might | |
" have made, as well as sanely reset options when re-sourcing .vimrc | |
set nocompatible | |
" Attempt to determine the type of a file based on its name and possibly its | |
" contents. Use this to allow intelligent auto-indenting for each filetype, | |
" and for plugins that are filetype specific. | |
filetype indent plugin on | |
" Enable syntax highlighting | |
syntax on | |
" This option enables the re-use the same window and switch from an unsaved | |
" buffer without saving it first. Also allows you to keep an undo history for | |
" multiple files when re-using the same window in this way. Note that using | |
" persistent undo also lets you undo in multiple files even in the same window, | |
" but is less efficient and is actually designed for keeping undo history after | |
" closing Vim entirely. Vim will complain if you try to quit without saving, | |
" and swap files will keep you safe if your computer crashes. | |
set hidden | |
" Better command-line completion | |
set wildmenu | |
" Show partial commands in the last line of the screen | |
set showcmd | |
" Highlight searches (use <C-L> to temporarily turn off highlighting; see the | |
" mapping of <C-L> below) | |
set hlsearch | |
" Disable modelines for improved security | |
set nomodeline | |
" Use case insensitive search, except when using capital letters | |
set ignorecase | |
set smartcase | |
" Allow backspacing over autoindent, line breaks and start of insert action | |
set backspace=indent,eol,start | |
" When opening a new line and no filetype-specific indenting is enabled, keep | |
" the same indent as the line you're currently on. Useful for READMEs, etc. | |
set autoindent | |
" Stop certain movements from always going to the first character of a line. | |
" While this behaviour deviates from that of Vi, it does what most users | |
" coming from other editors would expect. | |
set nostartofline | |
" Display the cursor position on the last line of the screen or in the status | |
" line of a window | |
set ruler | |
" Always display the status line, even if only one window is displayed | |
set laststatus=2 | |
" Instead of failing a command because of unsaved changes, instead raise a | |
" dialogue asking if you wish to save changed files. | |
set confirm | |
" Use visual bell instead of beeping when doing something wrong | |
set visualbell | |
" And reset the terminal code for the visual bell. If visualbell is set, and | |
" this line is also included, vim will neither flash nor beep. If visualbell | |
" is unset, this does nothing. | |
set t_vb= | |
" Disable the use of the mouse for all modes | |
set mouse= | |
" Set the command window height to 2 lines, to avoid many cases of having to | |
" "press <Enter> to continue" | |
set cmdheight=2 | |
" Display line numbers on the left | |
" An alternative is to use relativenumber, but contrary ot the usual vim ways, | |
" a visual line + delete does the job better for me | |
set number | |
" Quickly time out on keycodes, but never time out on mappings | |
set notimeout ttimeout ttimeoutlen=200 | |
" Use <F11> to toggle between 'paste' and 'nopaste' | |
set pastetoggle=<F11> | |
" Indentation settings for using 4 spaces instead of tabs. | |
" Do not change 'tabstop' from its default value of 8 with this setup. | |
set shiftwidth=4 | |
set softtabstop=0 | |
set expandtab | |
set smarttab | |
" Indentation settings for using hard tabs for indent. Display tabs as | |
" four characters wide. | |
set tabstop=4 | |
set softtabstop=0 | |
" Map Y to act like D and C, i.e. to yank until EOL, rather than act as yy, | |
" which is the default | |
map Y y$ | |
" Map <C-L> (redraw screen) to also turn off search highlighting until the | |
" next search | |
nnoremap <C-L> :nohl<CR><C-L> | |
" Map <C-n> and <C-p> to cycle between open buffers | |
nnoremap <C-n> :bnext<CR> | |
nnoremap <C-p> :bprevious<CR> | |
" Map <M-Up> and <M-Down> to move the line up and down, respectively, in... | |
" ... normal mode | |
nnoremap <M-Up> :m-2<CR>== | |
nnoremap <M-Down> :m+<CR>== | |
" ... insert mode | |
inoremap <M-Up> <Esc>:m-2<CR>==gi | |
inoremap <M-Down> <Esc>:m+<CR>==gi | |
" ... visual mode | |
vnoremap <M-Up> :m '<-2<CR>gv=gv | |
vnoremap <M-Down> :m '>+1<CR>gv=gv | |
" ... and map <C-S-n> and <C-S-p> to cycle through buffers by incrementing resp. | |
" decrementing buffer IDs. This allows cycling between unlisted buffers | |
" as well. | |
" Why isn't the shift working?? | |
"nnoremap <C-S-n> :execute ":buffer ".(bufnr("%") + 1)<CR> | |
"nnoremap <C-S-p> :execute ":buffer ".(bufnr("%") - 1)<CR> | |
"------------------------------------------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment