Mainly configured for web development (for now at least) with the default nvim console (not nvim-qt)
I tried to keep everything tidy (it might get a little disordered when is uploading to the repository because I usually use notepad ++ to edit it quickly and the tabs are taken differently in GitHub). For now it is ideally designed to use the configuration in windows (and with the limitations that that brings) together with the windows terminal, I have a configuration for that also in this other repository and it is the one I currently use
Maybe it lacks a bit of optimization, so if you notice poor performance I recommend that you leave activated only what you consider necessary, in ".vimrc" I try to give a description of what exactly does each thing so you can edit everything more easily
(optional)
- Use the Windows Terminal
(necessary)
- Have vim and nvim installed
- A plugin manager (I personally use Vim-Plug), but you can safely use any other, for example Vim-Vundle, and you would only have to change the lines to suit your plugin manager.
For example using Vim-Vundle you would have to change the following:
set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " And any other plugin you want to change Plugin 'tpope/vim-fugitive' call vundle#end()
- Once you have a plugin manager you will have to install the plugins that are in ".vimrc", in case of using vim-plug, you only have to put this command in the console and you should install them
:PlugInstall
- If the icons do not load I recommend installing this font LiterationMono Nerd Font or any other font from Nerd Font
- To use the plugins you will also need:
- node or nvm-windows
- python
Additionally you can improve the autocomplete for python by installing the following packagespip3 install pynvim pip3 install neovim pip3 install -U setuptools pip3 install python-language-server pip3 install 'python-language-server[all]' pip3 install git+git:https://github.com/psf/black pip3 install pyls-mypy pip3 install pyls-isort pip3 install pyls-black
You can configure everything to your liking, I leave it as it is more comfortable for me, below I will also describe most of the keyboard shortcuts (which are generally the defaults of the X plugin in particular)
(optional)
-
If you use git, Vim-gitgutter will need you to specify the path to your git.exe directory, For example changing to the path where you have it installed (this line is inside ".vimrc" and is the default where git is install, so you may not need to change anything):
let g: gitgutter_git_executable = 'C:\Program Files\Git\bin\git.exe'
-
There is an option enabled in the configuration (.vimrc) that will autosave the view (this includes, for example, where you were positioned before closing the file, if you created folds, they will also be saved, etc.)
" save the folds in the .vim/view directory autocmd BufWinLeave . mkview autocmd BufWinEnter . silent loadview
but it may generate lag and also it will execute with each new file and it will generate an error message if it is a new file (only the first time), it will also generate a folder called "view" in the nvim folder and in the vim folder
In windowsC:\Users\ttuna\AppData\Local\nvim-data\view
orC:\Users\ttuna\.vim\view
That is why if it bothers you to have this enabled it is better that you delete it from the .vimrc
-
Conquer of Completion for autocomplete
Coc extensions -
ultisnips for snippets in Vim using CoC
- vim-snippets pack of snippets
- monokai theme a simple theme for vim that I liked, nothing special
- vim-airline to make the statusline more beautiful
- vim-airline-themes themes for the plugin above
- vim-devicons displays icons according to file type
- nerdtree file system explorer, to navigate between files in a more intuitive way
- nerdtree-git-plugin a plugin of NERDTree showing git status
- vim-nerdtree-syntax-highlight adds syntax-highlight for nerdtree on most common file extensions
- ctrlp-vim to find and manipulate buffers more quickly
- vim-buffergator buffergator is a plugin for listing, navigating between, and selecting buffers to edit. (this could be removed if you wish, ctrlp almost already does the same job)
- vim-tmux-navigator for navigate seamlessly between vim and tmux splits using a consistent set of hotkeys
- vim-easymotion to move much faster while editing
- vim-smoothie for smooth scrolling
- vim-gitgutter shows which lines have been added, modified, or removed when using git
- vim-fugitive to use git commands more quickly
- vim-closetag auto close (X)HTML tags
- auto-pairs for insert or delete brackets, parens, quotes in pair.
- vim-sandwich set of operator and textobject plugins to search/select/edit sandwiched textobjects
- emmet-vim emmet-vim is a vim plug-in which provides support for expanding abbreviations similar to emmet
- winresizer very simple vim plugin for easy resizing of your vim windows
- vim-polyglot something like prettier but for many more languages and vim
- nerdcommenter for commenting operations and styles
- vim-titlecase support for motions and text objects
I will describe the ones that I personally use most often because otherwise the list would be very long
My current mapleader is space, so Leader === space
Shortcut | Mode | Description |
---|---|---|
<Leader>w |
Normal | save the current file |
<Leader>W |
Normal | save and exit the current file |
<Leader>q |
Normal | quit file (error if not saved) |
<Leader>qq |
Normal | quit the current file (use with care) |
<Leader>R |
Normal | quit all buffers (error if not saved) |
<Leader>QQ |
Normal | quit and save all buffers |
<Leader>1 |
Normal | to open a new tab (write the name of the file you want to open) |
<Leader>L |
Normal | to navigate one tab to the right |
<Leader>H |
Normal | to navigate one tab to the left |
<Leader>2 |
Normal | to close the current tab |
<Leader>3 |
Normal | to save the session and all the files you have open (make up a name ending in '.vim') then to open it use 'vim -S name.vim' |
<Leader><C-h> |
Normal | to go to the beginning of the line (visual mode) |
<Leader><space>h |
Normal | to go to the beginning of the line |
<Leader><C-l> |
Normal | to go to the end of the line (visual mode) |
<Leader><space>l |
Normal | to go to the end of the line |
° |
Normal | to simulate enter key |
jk |
Insert | to exit insert mode |
<Leader>l |
Normal | to tell easymotion that we want to go right |
<Leader>k |
Normal | to tell easymotion that we want to go up |
<Leader>j |
Normal | to tell easymotion that we want to go down |
<Leader>h |
Normal | to tell easymotion that we want to go left |
s |
Normal | to activate easymotion 2 keys |
<Leader><Leader>s |
Normal | to activate easymotion 1 keys |
<Leader>rn |
Normal | to rename a variable |
<Leader>ci |
Normal | to comment the current line / same to uncomment |
<Leader>b |
Normal | trigger buffergator |
<Leader>p |
Normal | trigger ctrlp |
<Leader>n |
Normal | trigger nerdtree |
<c-space> |
Insert | for trigger CoC completion |
K |
Normal | show CoC documentation |
<c-n> or <c-j> |
Normal | to navigate between CoC autocomplete |
<c-f> |
Normal | to cycle between ctrlp modes |
<C-x>n |
Normal | emmet-goto-next-point |
<C-x>N |
Normal | emmet-goto-previous-point |
Vsa( |
Normal | sandwich the current word with a parenthesis (you can use "(","[","{") |
V2jsd |
Normal | being at the beginning of the parenthesis de-sandwich the current word, also works with ("(","[","{") |
<C-a> |
Normal | trigger winresizer |
O |
Normal | fix and escape from window resize mode |
gb or gB |
Normal | to flip through the most-recently used buffer stack without opening the buffer listing "drawer". |
<Leader>to |
Normal | to open the tab page catalog (buffergator) |
<Leader>gs |
Normal | to activate the interactive vim fugitive menu |
<Leader>gk |
Normal | to jump to the next difference (using vimdiff) |
<Leader>gj |
Normal | to go back to the previous difference (using vimdiff) |
<Leader>gu |
Normal | to scan the document again in case of new differences (using vimdiff) |
<Leader>gh |
Normal | to choose the update on the left (using vim fugitive) |
<Leader>gl |
Normal | to choose the update on the right (using vim fugitive) |
<Leader>5 |
Normal | to restart CoC in case of bugs |
-
Using ultisnips and CoC when you complete a snippet you can use the 'tab' key to jump to the next field to complete
-
Shift + v
to enter block select mode,zf
(to create a fold),zo
(to open a fold),zc
(to close a fold),zd
(to delete a fold),:Fold<CR>
(coc plugin) orzm
(to fold all the text in the current buffer),zr
to open all the folds.
Tip: you can use the key combinationggVG
to select all the text and usezo
to open the folds or some other command
Note:z*
fold methods only work when the method is manual or marker:set foldmethod=manual
or:set foldmethod=marker
-
:diffget
and:diffput
can be abbreviated asdo
anddp
respectively
To obtain the latest features of our plugins and plugin managers, we will need to update them from time to time
In order to update the plugin manager that I use (in this case it would be "Plug") we will need to put this command in the console and execute it
:PlugUpgrade
(each plugin manager may have a different way to update it)
Once an update is applied, I always recommend restarting nvim so that it does not throw errors if we continue to update something else. To update the plugins we are using (for example, coc, fugitive, ctrlp, nerdtree, etc) we will have to use this other command
:PlugUpdate
And finally to update the CoC extensions we are going to use the following command (as I mentioned above it is better to restart before executing it)
:CocUpdate
- jdhao I personally think that I will migrate to this configuration in the future
- benawad
- joshldavis