OMG! I'm feeling weird coding in a project this week, the guilty, that little text editor called Vim.
I've always had Vim as a second editor; I used it for small sporadic things. But, the excellent productivity of which many posts on internet talk when you start to be confident using Vim made me want to use it for something more than small edits. Although feeling trapped trying to guess a key combination made me gave up and come back to my regular text editor.
This week I was starting a side project, and I thought it would be an excellent opportunity to use Vim. Start a project from scratch is a unique way to keep everything under control.
I didn't want to make the same past mistakes. This time, I decided to start differently. The first three steps I did:
Delete my beloved old editor.
This step will prevent temptations to come back to it.
Delete my .vimrc configuration.
As I said before, I had Vim as the second editor, and I had the .vimrc file with a lot of lines I copied from tutorials, and I didn't remember what all that lines do.
Delete my .vim folder.
A hell of plugins I had in this folder, plugins I installed when I read about it and never use again. Plugins are great, but I think it can be the worst enemy when you are starting because it can increase even more the learning curve.
With an empty Vim, one of the first tasks that came to my mind was the need for a file system explorer. Quickly I remembered NERDtree, but seconds later, the vision of a .vim folder full of plugins again made me stop. Much better start with what Vim offers, and if I need something more, I can extend functionalities with plugins. For now, just Vim.
Netrw is the Vim's native file browser, make possible browsing over a network and local files, plus I don't need to install anything extra to use it, so far, sounds great to me. When I want to look around before editing files, I use:
vim . or
vim /path/to/project and if If I find myself lost
:h netrw will show me the documentation about Netrw.
After play around a bit with Netrw I added some extra configuration to fit Netrw in my workflow, I added the next lines in my .vimrc file
" The default listing style I like, one file per line with file size and time stamp let g:netrw_liststyle =1 " Directories on the top, files below let g:netrw_sort_sequence ='[\/]$,*' " Keep the cursor in the netrw window let g:netrw_preview =1 " Open files in vertical let g:netrw_altv =1 " Allow netrw to remove non-empty local directories let g:netrw_localrmdir ='rm -r' " Invoking netrw in a split vertical window nnoremap <Leader><Space> :Vex<CR> " Move next in the buffer of files nnoremap <Space> :bnext<CR> " Move back in the buffer of files nnoremap <Bs> :bprev<CR> " Invoke newtrw in the current directory nnoremap <Leader>- :E<CR> " Go up in the directories nnoremap <Plug>(NetrwUp) :e.<CR> if empty(maparg('-', 'n')) nmap - <Plug>(NetrwUp) endif
Coding in the project with this configuration and I already don't miss at all the tree-view from my old editor. Space and Backspace have become in my new favourite keys and
<Leader>- are fantastic for file exploring.
By now, I have more than enough; let's see when the project starts to grow what more I need.
Single Responsibility Principle (or SRP) is one of the most important concepts in software development. The main idea of this concept is: all pieces of software must have only a single responsibility.