This is how I code with sublime text

It is so true that many of us hate doing repetitive tasks. Recently I have to code a bunch of stuff which involved mundane manual editing. To help you understand the situation, I have a set of comma separated strings(left) and I have to convert each of them to the right side view(C# properties). The list of strings I have to work with was horribly long.
This time I turned my attention to Sublime text. Sublime text and most modern text editors have a feature called multi cursor/multi selection editing. What this enables us to do is, create multiple cursors instead of traditional single cursor editing. Sublime text of course has the superior support when it comes to this feature. In essence, With multiple cursors you can edit multiple regions of the document simultaneously! Multiple cursors can be created manually by Ctrl+Mouse Click.
Read on →

How to find the total number of lines in a text file using notepad?

These days most of us use much better text editors than Notepad. But yesterday I found a neat little trick to find the current line number and eventually the total number of lines in a text file using notepad from my colleague Nandan Prabhu. Generally when you press Ctrl+G notepad will pop up the Go to Line dialog. Inside this dialog is the (hidden) current line number information pre-filled by Notepad. So we can use this pre-filled info to find the total number of lines in the opened text file by going to the end of the file and pressing Ctrl+G ;). This may not be an earth shattering discovery! But may be useful if you don’t have access to any other tools other than Notepad.
Read on →

How to enable spell checking in Vim

One task which I do often during writing git commit message is making sure my commit message don’t have any spelling mistakes. I use Vim a lot and today we will see how Vim’s built-in spell checking features can be used for this task.

Content with spelling mistakes
Content with spelling mistakes
:set spell

triggers Vim spell checking functionality on the currently opened buffer.

Vim highlighting misspelled words
Vim highlighting misspelled words
  1. [s  move backward to each misspelled word
  2. ]s  move forward to each misspelled word
  3. z= Once you are on the misspelled word this will show list of suggestions as shown below
Vim showing suggestions
Vim showing suggestions
:set nospell

The above command will turn off the spell check in Vim.

All spellings corrected!
All spellings corrected!


Adding the following lines to your ~/.vimrc will automatically highlight incorrect spellings during git commit message as shown below

au BufNewFile,BufRead COMMIT_EDITMSG set spell
hi clear SpellBad
hi SpellBad cterm=underline
hi clear SpellCap
hi SpellCap cterm=underline
hi clear SpellRare
hi SpellRare cterm=underline
hi clear SpellLocal
hi SpellLocal cterm=underline
Auto Spell Check in VIM on git commit message
Auto Spell Check in VIM on git commit message

Vim Revisited

  1. P for pasting before the cursor
  2. cc delete entire line and goto insert mode
  3. zt Move the current line to the top of the screen
  4. zz Move the current line to the middle of the screen
  5. zb Move the current line to the bottom of the screen
  6. H Move the cursor to the top of the screen
  7. M Move the cursor to the middle of the screen
  8. L Move the cursor to the last of the screen
  9. Replace a word just with in a function
    • goto to the function starting { brace.
    • Change to visual mode by press v
    • then press % to select entire function body.
    • then : once the scope of the replacement is already filled by vim
    • start typing the substitute command as s/word/replace