What are some .vimrc essentials? Post your .vimrc

What are some .vimrc essentials? Post your .vimrc

Attached: flat800x800070f.jpg (800x800, 86K)

Other urls found in this thread:

vim.wikia.com/wiki/Accessing_the_system_clipboard
github.com/Mark-Weston/silva-rerum/blob/master/nanorc
twitter.com/NSFWRedditImage

command! WipeReg for i in range(34,122) | silent! call setreg(nr2char(i), []) | endfor
"autocmd VimEnter * WipeReg

first line sets WipeReg command. This does what you think it does.
Second line will do this when starting vim if you uncomment the line (remove leading ")
I never actually use this, I just think it's cool. :^)

I just set numberlines to show. That's it.

:set mouse=a

enable resizing and switching focus on viewports using mouse.
:set shortmess+=I

Strop reminding me about Ugandan children.
:map :set paste
:map :set nopaste
:imap :set paste
:imap
:set pastetoggle=

If you don't have system clipboard support, vim will mess up indenting of pasted code. This is the workaround found in
:help pastetoggle
but with keybinds that don't confict with gnome-terminal's existing ones.
>I actually do has "+ register, but leave that in for the sake of portability.

set hlsearch
syntax on
set number
filetype plugin indent on
" show existing tab with 4 spaces width
" set tabstop=4
" " when indenting with '>', use 4 spaces width
" set shiftwidth=4
" " On pressing tab, insert 4 spaces
" set expandtab
filetype plugin on
set showmatch
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"")

:highlight Normal ctermfg=Grey ctermbg=Black
highlight DiffAdd cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffDelete cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffChange cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffText cterm=bold ctermfg=10 ctermbg=88 gui=none guifg=bg guibg=Red

First line is general color scheme, and the rest is for diff mode. Easier on the eyes imo.

" integrate with X11s clipboard, in particular, alias the X11 clipboard
" (CTRL+C) register in vim (the + register) to the default unnamed register
" vim.wikia.com/wiki/Accessing_the_system_clipboard
set clipboard=unnamedplus

set shiftwidth=4
set autoindent
set tabstop=4

these are the absolute essentials

If you use NerdTree for example and type :q in the main window it closes, leaving the NerdTree Window open, wich then you have to close again by another :q
This lets you quit both at once.

autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

Another cool thing is when you forgot to sudo and can't save the file without opening it again with sudo vim

cmap w!! w !sudo tee > /dev/null %

*map y "+y
*map p "+p
*map Y "*y
*map P "*p

What text editor does ol' sammy boy use?

completion dropdown functions like in your babby IDEs

" makes the enter key select from list, not \n
inoremap pumvisible() ? "\" : "\u\"

" simulate a down-press so that something is always highlighted
inoremap pumvisible() ? '' : '=pumvisible() ? "\Down>" : ""'
inoremap pumvisible() ? '' : '=pumvisible() ? "\Down>" : ""'

show relative line numbers in normal mode, absolute numbers in insert mode
" show line numbers
set number relativenumber
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END

the search function isn't case sensitive unless you use an uppercase character in your query
" search ignores case unless uppercase given
set ignorecase smartcase

github.com/Mark-Weston/silva-rerum/blob/master/nanorc

Here's a small function i wrote that makes the current window the length of the line + 20 chars. I find it very useful when you have low screen space plus long lines. I have it bound to gl.

function! LineWidth()
execute("vertical resize " . (strlen(getline(".")) + 20))
endfunction

nnoremap q:
nnoremap q/
nnoremap q?
nnoremap Q: q:
nnoremap Q/ q/
nnoremap Q? q?

bump

syntax off

set autoindent
set backup
set backupdir=~/.backup
set undodir=~/.backup
set relativenumber
set ruler
set softtabstop=-1

map! jj

map h
map j
map k
map l

map wm :update|make

au BufRead *.c %!indent -linux -

au BufRead *.py setlocal expandtab shiftwidth=4 makeprg=python\ -Bi\ %

set incsearch

And what exactly do you think I think it does?

A blank .vimrc