Skip to content

Instantly share code, notes, and snippets.

@neilpanchal
Created January 19, 2021 06:14
Show Gist options
  • Save neilpanchal/b469865504e76f981392dade267bb6ab to your computer and use it in GitHub Desktop.
Save neilpanchal/b469865504e76f981392dade267bb6ab to your computer and use it in GitHub Desktop.
RIP vim. I did try.
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" Neil's .vimrc file.
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set nocompatible " NEVER change this! Use Vim mode, not vi mode.
filetype plugin indent on " Enable automatic settings based on file type
syntax on " Enable colour syntax highlighting
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" Options
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" Use :help 'option (including the ' character) to learn more about each one.
" Buffer (File) Options:
set hidden " Edit multiple unsaved files at the same time
set confirm " Prompt to save unsaved changes when exiting
" Keep various histories between edits
set viminfo='1000,f1,<500,:100,/100,h
" Search Options:
set hlsearch " Highlight searches. See below for more.
set ignorecase " Do case insensitive matching...
set smartcase " ...except when using capital letters
set incsearch " Incremental search
" Insert (Edit) Options:
set backspace=indent,eol,start " Better handling of backspace key
set autoindent " Sane indenting when filetype not recognised
set cindent " Automatically indent after pressing Enter
set smartindent " Same as above
set nostartofline " Emulate typical editor navigation behaviour
set nopaste " Start in normal (non-paste) mode
set pastetoggle=<f11> " Use <F11> to toggle paste modes
" Status / Command Line Options:
set wildmenu " Better commandline completion
set wildmode=longest:full,full " Expand match on first Tab complete
set showcmd " Show (partial) command in status line.
set laststatus=2 " Always show a status line
set cmdheight=2 " Prevent "Press Enter" messages
" Show detailed information in status line
set statusline=%f%m%r%h%w\ [%n:%{&ff}/%Y]%=[0x\%04.4B][%03v][%p%%\ line\ %l\ of\ %L]
" Interface Options:
set number " Display line numbers at left of screen
set visualbell " Flash the screen instead of beeping on errors
set t_vb= " And then disable even the flashing
set mouse=a " Enable mouse usage (all modes) in terminals
" Quickly time out on keycodes, but never time out on mappings
set notimeout ttimeout ttimeoutlen=200
" Indentation Options:
set tabstop=8 " NEVER change this!
" Change the '2' value below to your preferred indentation level
set shiftwidth=2 " Number of spaces for
set softtabstop=2 " ...each indent level
set shortmess+=I " Disable the default Vim startup message.
set number relativenumber " Show relative line numbers.
set backspace=indent,eol,start " Set backspace key to something reasonable.
" When entering insert mode, relative line numbers are turned off,
" leaving absolute line numbers turned on.
:augroup numbertoggle
: autocmd!
: autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
: autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
:augroup END
" Disable audible bell because it's annoying.
set noerrorbells visualbell t_vb=
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" Maps
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" F1 to be a context sensitive keyword-under-cursor lookup
nnoremap <F1> :help <C-R><C-W><CR>
" Reformat current paragraph
nnoremap Q gqip
" Move cursor between visual lines on screen
nnoremap <Up> gk
nnoremap <Down> gj
" 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>
" Toggle search highlighting
nnoremap <C-Bslash> :set hls!<bar>:set hls?<CR>
inoremap <C-Bslash> <Esc>:set hls!<bar>:set hls?<CR>a
" Unbind some useless/annoying default key bindings.
nmap Q <Nop> " 'Q' in normal mode enters Ex mode. You almost never want this.
" Disable arrow keys
nnoremap <Left> :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up> :echoe "Use k"<CR>
nnoremap <Down> :echoe "Use j"<CR>
inoremap <Left> <ESC>:echoe "Use h"<CR>
inoremap <Right> <ESC>:echoe "Use l"<CR>
inoremap <Up> <ESC>:echoe "Use k"<CR>
inoremap <Down> <ESC>:echoe "Use j"<CR>
set noswapfile
let &t_SI = "\<ESC>]50;CursorShape=1\x7"
let &t_SR = "\<ESC>]50;CursorShape=2\x7"
let &t_EI = "\<ESC>]50;CursorShape=0\x7"
nnoremap <silent> <ESC><ESC> <ESC>:nohlsearch<CR><ESC>
highlight LineNrAbove term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE
highlight LineNrBelow term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" Auto commands
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
if has("autocmd")
augroup filetype
" Remove ALL autocommands for the current group.
autocmd!
" Jump to last-known-position when editing files
" Note: The | character is used in Vim as a command separator (like ; in C)
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
endif
" Vim-plug
call plug#begin()
Plug 'tpope/vim-sensible'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'https://github.com/dahu/VimGym.git'
call plug#end()
@neilpanchal
Copy link
Author

I've learned a bunch from this experiment. Most cool things that vim has to offer can be done with mouse + multiple cursors + regex in PyCharm. Kudos to Ideavim, that extention is outstanding emulation of the real thing and it's super fast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment