Working with multiple files

When we open nvim, what we see is a window in a tab. The window is the viewport that holds the buffers. When we open a file, we are actually copying the contents of the file onto a buffer and when we make changes to that copy and write :w, the contents of the buffer is written in that file thus changing it. When we open multiple files each file will open in it’s own buffer. The window will display only the active buffer while the other buffers will be hidden. We can check the files in the buffers with the command buffers. We can switch to a buffer with the command :b<buffer number>. To close the active buffer we use the command :bd. To close a hidden buffer we use the command :bd<buffer number>. If you didn’t write your chabges before closing a buffer nvim will ask you to first write and then close. If you don’t want to write the changes, you can use the command :bd!.

A tab can have multiple windows. Thus in a tab we can have multiple windows open through horizontal split :hsplit or :split or vertical split vsplit.

Tabs, spaces and end of line Working with python means being very careful

about not having wrong indentations in your code. While there are plugins that shows indentation line, I wanted to achieve that with as much inbuilt commands as possible. Luckily I stumbled upon this amazing resource [Vimcasts] .

We can use nvim’s list feature to show hidden characters. To turn it on we just have to execute the command set list!. By default it only shows tabs and leading and trailing spaces. I have configured the init.vim file to also show the eol by adding the command set listchars=tab:▸\ ,eol:¬,lead:-,trail:- to my config file.

Markdown underscore highlighting

While working with markdown files, there will be a lot of times when the underscore character will be highlighted. I find it very annoying. To remove the highlight, we need to change the highlight group from markdownError to Normal. We can do this using the command :hi link markdownError Normal

Force text to 80 columsn for markdown files

Add the follwing command to your config file: au BufRead,BufNewFile *.md setlocal textwidth=80

Now nvim should restrict textwidth to 80 columns for markdown files. It will automatically break the line if it exceeds 80 columns.

If there are lines in the document that increase the textwidth, we can format them by going to the top of the document and using the command gqG.

[Reference: Stackoverflow]