Hi everyone, lately I have been enjoying my neovim setup a lot so I decided to share some settings and plugins that you might find neat and helpful. Let's go!
Mappings
Here the mappings I consider important in my vim configuration.
First, I like to map the leader to space. This feels way more natural than using \
when typing.
let mapleader = "\<space>"
We continue with:
inoremap <C-c> <esc>
nnoremap ; :
" quick-save
nmap <leader>w :w<CR>
" close buffer without changing window layout
nnoremap :: :bp\|bd #<CR>
A feature I use a lot in vscode
is the ability to move lines up and down. Thanks to the primeagen (I love his energy and his vim skills are super human) I got to learn about these mappings to achieve the same result
" Moving lines up or down preserving format {
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
inoremap <C-j> <esc>:m .+1<CR>==gi
inoremap <C-k> <esc>:m .-2<CR>==gi
nnoremap <leader>j :m .+1<CR>==
nnoremap <leader>k :m .-2<CR>==
" }
Another mappings that make life easier
" set a column at position 100
set colorcolumn=100
highlight ColorColumn ctermbg=0 guibg=lightgrey
" select everything
nnoremap <C-A> ggVG
" open new file adjacent to current file
nnoremap <leader>o :e <C-R>=expand("%:p:h") . "/" <CR>
" toggle between buffers current and prev buffer
nnoremap <leader><leader> <c-^>
Plugins
Note: I personally use vim-plug but any vim plugin manager should work as well.
NERDCommenter
Not much to say about this one. I have it mapped to Ctrl+/
in this way
nmap <C-_> <Plug>NERDCommenterToggle
vmap <C-_> <Plug>NERDCommenterToggle<CR>gv
Vim-Airline
With this configuration
" Airline {
let g:airline_theme='papercolor'
" show git branch
let g:airline#extensions#branch#enabled=1
let g:airline#extensions#hunks#enabled=0
let g:airline_powerline_fonts=1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#fnamemod = ':t'
" }
Fugitive
Git integration. These are my configs
" Fugitive {
function! ToggleGStatus()
if buflisted(bufname('.git/index'))
bd .git/index
else
vertical Git | vertical resize 40
endif
endfunction
command ToggleGStatus :call ToggleGStatus()
nmap <F3> :ToggleGStatus<CR>
nmap <leader>gj :diffget //3<CR>
nmap <leader>gf :diffget //2<CR>
" }
Telescope
I'm just amazed but the amount of features of this plugin. Here my config that can give you some idea what is it about
" Telescope {
nnoremap <leader>ff <cmd>Telescope find_files<cr>
" open in current file pwd
nnoremap <leader>fc :lua require('telescope.builtin').file_browser({cwd = vim.fn.expand('%:p:h')})
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fr :lua require('telescope.builtin').registers()<CR>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
" display help tags for all extensions
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
nnoremap <leader>fk :lua require('telescope.builtin').keymaps()<CR>
nnoremap <leader>fz :lua require('telescope.builtin').current_buffer_fuzzy_find()<CR>
" show all your colorschemes to try
nnoremap <leader>ft :lua require('telescope.builtin').colorscheme()<CR>
" }
vim-visual-multi
Let's you have multiple cursor as in vscode
Color Schemes
I have installed awesome-vim-colorschemes and I love PaperColor
at the moment. Here an example of a go
file.
That's all.
You can check my init.vim
at my dotfiles repo.
Do you have any awesome config to share? Please leave a comment 🚀
Top comments (0)