Skip to content

Instantly share code, notes, and snippets.

@lowercasename
Last active June 9, 2021 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lowercasename/066f3289e1e26e2d963c4fbd8a4aad37 to your computer and use it in GitHub Desktop.
Save lowercasename/066f3289e1e26e2d963c4fbd8a4aad37 to your computer and use it in GitHub Desktop.
call pathogen#infect()
syntax on
filetype plugin indent on
set mouse=a
set number
" Turns on auto-indent
set autoindent
" Replace tabs with spaces (Ctrl-V<TAB> to type actual tab)
set expandtab
" Tab characters count for 8 spaces (?)
set tabstop=8
" Indent by 4 spaces
set shiftwidth=4
" Usually tabs to the right location
set smartindent
" Make backspace work predictably
set backspace=indent,eol,start
filetype plugin indent on
" Save swap files in a temp directory
set directory^=$HOME/.vim/tmp//
" Needed for lightline (?)
set laststatus=2
set noshowmode
let g:lightline = {
\ 'colorscheme': 'apprentice',
\ }
" Show number of matching search results in the statusline
set shortmess-=S
" fzf
set rtp+=/usr/local/opt/fzf
" let g:fzf_colors = {
" \ 'border': ['fg', 'Comment'],
" \ }
" Switch tabs with Shift-H and Shift-L
nnoremap H gT
nnoremap L gt
"Open NerdTree with Ctrl-N
nnoremap <C-n> :NERDTreeToggle<CR>
" Open FZF with Ctrl-F
nnoremap <C-f> :FZF<CR>
" Shift lines up and down with Shift-j and Shift-k
nnoremap <S-j> :m .+1<CR>==
nnoremap <S-k> :m .-2<CR>==
" Tab and Shift-Tab in Insert and Normal mode tab/untab a line
inoremap <Tab> <C-t>
inoremap <S-Tab> <C-d>
nnoremap <Tab> <C-t>
nnoremap <S-Tab> <C-d>
" Tab navigation like Firefox.
" nnoremap <C-S-tab> :tabprevious<CR>
" nnoremap <C-tab> :tabnext<CR>
" nnoremap <C-t> :tabnew<CR>
" inoremap <C-S-tab> <Esc>:tabprevious<CR>i
" inoremap <C-tab> <Esc>:tabnext<CR>i
" inoremap <C-t> <Esc>:tabnew<CR>
" Save and restore session
command Save :mksession! ~/.vimsession <cr>
command Restore :source ~/.vimsession <cr>
" Source .vimrc file
command S :source ~/.vimrc
"This unsets the 'last search pattern' register by hitting return
nnoremap <CR> :noh<CR><CR>
" Open ripgrep entries in new tab with C-T
augroup quickfix_tab | au!
au filetype qf nnoremap <buffer> <C-t> <C-w><CR><C-w>T
augroup END
" Wrap around when navigating marks
nnoremap <silent> ]' :call CycleMarks("]'")<cr>
nnoremap <silent> [' :call CycleMarks("['")<cr>
nnoremap <silent> ]` :call CycleMarks("]`")<cr>
nnoremap <silent> [` :call CycleMarks("[`")<cr>
function! CycleMarks(arg)
let currentPos = getpos(".")
execute "normal! " . a:arg
let newPos = getpos(".")
if newPos == currentPos
if a:arg == "]'" || a:arg == "]`"
execute "normal! gg0" . a:arg
else
execute "normal! G$" . a:arg
endif
endif
endfunction
" vim-markbar
let g:markbar_marks_to_display = 'abcdefghiABCDEFGHI'
let g:markbar_peekaboo_marks_to_display = 'abcdefghiABCDEFGHI'
let g:markbar_width = 80
let g:markbar_peekaboo_width = 80
nmap <Leader>m <Plug>ToggleMarkbar
" Console log from insert mode; Puts focus inside parentheses
" The Ctrl-V prevents the bracket autocloser from activating
imap cll console.log<C-v>();<Esc><S-f>(a
" Console log from visual mode on next line, puts visual selection inside parentheses
vmap cll yocll<Esc>p
" Console log from normal mode, inserted on next line with word your on inside parentheses
nmap cll yiwocll<Esc>p
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
:autocmd InsertEnter * set cul
:autocmd InsertLeave * set nocul
" Theme
set termguicolors
" set t_Co=256
set background=dark
colorscheme apprentice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment