Skip to content

Instantly share code, notes, and snippets.

@Elteoremadebeethoven
Last active April 3, 2024 06:20
Show Gist options
  • Save Elteoremadebeethoven/40c48f712f6a4937b7193d9bdc6cae00 to your computer and use it in GitHub Desktop.
Save Elteoremadebeethoven/40c48f712f6a4937b7193d9bdc6cae00 to your computer and use it in GitHub Desktop.
Basic nvim config without plugins for tutorials in CoCalc
syntax on
set number "Show numbers
set tabstop=2 "Tabulator size is 2 spaces
set shiftwidth=2 "Every 2 spaces is a tabulator
set expandtab "Convert tabulator to spaces
set autoindent
set mouse=a "Enable mouse
set undofile "Enable undo history
set undodir=~/.config/nvim/undo "set undo file
"Set <leader> == <space>
let mapleader = " "
"CoCalc fix
map <leader>w <c-w>
"Remove highlight
map <leader>h :noh<CR>
"Delete small word and big word
map <leader>d diw
map <leader>D diW
"Change ^ to 00
nmap <leader>0 ^
"Move blocks code up/down
nmap <A-j> :m .+1<CR>==
nmap <A-k> :m .-2<CR>==
imap <A-j> <Esc>:m .+1<CR>==gi
imap <A-k> <Esc>:m .-2<CR>==gi
vmap <A-k> :m '<-2<CR>gv=gv
vmap <A-j> :m '>+1<CR>gv=gv
"Save file changes
nmap <c-s> :w<CR>
imap <c-s> <ESC>:w<CR>a
"Move focus buffer
map <C-h> <C-w>h
map <C-k> <C-w>k
map <C-j> <C-w>j
map <C-l> <C-w>l
"Move focus but with leader key
map <leader>h <C-w>h
map <leader>k <C-w>k
map <leader>j <C-w>j
map <leader>l <C-w>l
"Normal mode in shell
tnoremap <esc><esc> <C-\><C-n>
"Move from shell to other buffer
tnoremap <C-w>h <C-\><C-n><C-w>h<CR>
tnoremap <C-w>k <C-\><C-n><C-w>k<CR>
tnoremap <C-w>j <C-\><C-n><C-w>j<CR>
tnoremap <C-w>l <C-\><C-n><C-w>l<CR>
"Move over tabs
map <S-l> gt
map <S-h> gT
"Move position tabs
map <A-l> :tabmove +1<CR>
map <A-h> :tabmove -1<CR>
"Search selected visual: Not supported by CoCalc Neovim
"map <C-n> viw*
"map <C-space> viw*
"Search word
vmap <C-n> *
vmap <C-space>n *
"Hide numbers in shell Insert Mode
autocmd TermEnter * setlocal nonumber norelativenumber
"Show numbers in shell Visual Mode
autocmd TermLeave * setlocal number
"Prevent yank when paste code
vnoremap p "_dP
"Indent code blocks in Visual Mode
xnoremap > >gv
xnoremap < <gv
"colorscheme darkblue
imap <c-space> <c-n>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment