How to delete one word backward in Vim

The following is a sample of text opening in vim/neovim with line numbers: 1 What would be the command to delete one word backwards? 2 I know we can use ‘db’ to delete backword, and it would work 3 as what I wanted if the cursor is on the last character. Assuming that my cursor is under letter ‘a’ of the word ‘command’ in line 1, and I want to delete the whole word ‘command’....

August 8, 2023 · 2 min · 322 words · kenno

Vim Replace String 256 with <T_CO>

What was your first text editor when you started using Linux/Unix? Mine was pico. It was very easy to get started with and quite similar to nano. Then I moved to emacs and sticked with it for a long while. Eventually, I’ve switched to vim (or neovim), and that’s what I have been using until now. Well, the thing about text editor or may be this also applies to many other things, you’re only familiar with features that you constantly use....

May 9, 2021 · 2 min · 320 words · kenno

How to remove Ctrl-M characters from files

A short while back, after exporting my blog from WordPress to Hugo I noticed that there were some weird ^M characters in some files as shown in the following screenshot in blue. This is a special character, CTRL+M and can be removed using sed or vim. Using vim we can replace/substitute a text with the following command: %s/MATCH-TEXT/WITH-NEW-TEXT/g Therefore, we should be able to replace ^M, by typing CTRL+V then CTRL+M, with an empty space as so:...

January 6, 2019 · 1 min · 133 words · kenno

Remove trailing whitespace with VIM

Here’s a quick tip on how to get rid of unwanted trailing whitespace using vim. Let’s say, I have the following code: Open that file with vim. The following command deletes any trailing white spaces. :%s/\s\+$//e Here’s the screenshot of the text after removing the whitespace: In search, \s finds whitespace (a space or tab). \+ finds one or more occurrences. $ matches the end of line, finally e flag means no error is displayed....

July 27, 2017 · 1 min · 96 words · kenno

How to toggle between buffers in Vim with vim-airline

First if you haven’t yet heard about vim-airline plugin, and you’re a Vim user, you really owe it to yourself to check it out. By default vim-airline displays the opening buffers on the top part of the window. So how to navigate between those buffers? Well, according to this, it seems those buffers are for visual only. To navigate between them, we can use :bp for previous buffer, and :bn for next buffer....

January 29, 2017 · 1 min · 116 words · kenno

vim-youcompleteme

I need to setup vim-youcompleteme to get real-time completion for write Golang code. Assuming that this part has been completed first: $ cd ~/.vim/bundle $ git clone https://github.com/fatih/vim-go.github Here’s how vim-youcompleteme is installed/enabled on Ubuntu 14.04: $ sudo apt-get install vim-addon-manager vim-youcompleteme $ vam install youcompleteme Note: vam is short for the vim-addon-manager. Reference: http://blog.gopheracademy.com/vimgo-development-environment/

December 5, 2014 · 1 min · 55 words · kenno

Turn on puppet syntax highlight in vim

On Debian/Ubuntu: $ sudo apt-get install vim-puppet $ ln -s /usr/share/vim/addons/syntax/puppet.vim ~/.vim/plugin/

September 21, 2012 · 1 min · 12 words · kenno

Vim backspace delete problem

In insert mode, backpace doesn’t delete characters as intended. To fix this issue, add this configuration to the .vimrc as the following: set backspace=indent,eol,start Reference: http://vim.wikia.com/wiki/Backspace_and_delete_problems

August 7, 2012 · 1 min · 26 words · kenno

Vim Tip: Insert Time-Stamp

To insert time-stamp in a file, you can exit from edit mode and type: :r! date

August 3, 2006 · 1 min · 16 words · kenno