Archive

Archive for the ‘vim’ Category

5 useful Vim plugins for developers

April 28, 2019 Leave a comment

I have used Vim as a text editor for over 20 years, but about two years ago I decided to make it my primary text editor. I use Vim to write code, configuration files, blog articles, and pretty much everything I can do in plaintext. Vim has many great features and, once you get used to it, you become very productive.

I tend to use Vim’s robust native capabilities for most of what I do, but there are a number of plugins developed by the open source community that extend Vim’s capabilities, improve your workflow, and make you even more productive.

Following are five plugins that are useful when using Vim to write code in any programming language.

1. Auto Pairs
2. NERD Commenter
3. Vim Surround
4. Vim Gitgutter
5. Vim Fugitive

https://opensource.com/article/19/1/vim-plugins-developers

Categories: vim Tags:

Vim as a Python IDE

February 1, 2019 Leave a comment

VIM as a Python IDE

This project aims to use Vim as a powerful and complete Python IDE. In order to do that, we curated a list of awesome plugins available in the community and provided an automatic installation procedure for this set.

https://rapphil.github.io/vim-python-ide/

Source:
https://www.pythonweekly.com/

Categories: Interesting, python, vim Tags:

ALE (Asynchronous Lint Engine)

December 4, 2018 Leave a comment

ALE (Asynchronous Lint Engine) is a plugin for providing linting in NeoVim 0.2.0+ and Vim 8 while you edit your text files, and acts as a Vim Language Server Protocol client.

ALE makes use of NeoVim and Vim 8 job control functions and timers to run linters on the contents of text buffers and return errors as text is changed in Vim. This allows for displaying warnings and errors in files being edited in Vim before files have been saved back to a filesystem.

In other words, this plugin allows you to lint while you type.

https://github.com/w0rp/ale

Categories: vim Tags: ,

Trying out code completion in vim

November 3, 2018 Leave a comment

Trying out code completion in vim. Installed `Youcompleteme`.

Steps:
1. The version of vim on macosx that I had did not have +python3 or +conceal that was needed with some of the completion engines that were installed.

# To check if vim has the needed versions
$ vim --version
+python3 # Supported
-python3 # Not supported

2. Install macvim

$ brew install macvim

Create an alias (Save this to .bashrc or .zshrc)

alias vim='mvim -v'

3. Install cmake

$ brew install cmake

4. Download YouCompleteMe and install using Pathogen

$ cd ~.vim/bundle
$ git clone https://github.com/Valloric/YouCompleteMe.git
$ git submodule update --init --recursive
$ cd YouCompleteMe
$ ./install.py --all

5. Edit some code

Source:
https://github.com/Valloric/YouCompleteMe
http://liuchengxu.org/posts/use-vim-as-a-python-ide/

Categories: vim Tags:

Different tabs for different files

September 14, 2018 Leave a comment

Problem:

Needed to have different tabs for different files when editing with vim. Eg in python tab == 4 spaces, in a MakeFile tab == tab.

Solution:

Added this to ~/.vimrc

" Use different indentation for yaml files
 autocmd FileType yaml,yml setlocal tabstop=2 expandtab shiftwidth=2 softtabstop=2

 " In makefiles, don't expand tabs to spaces, since actual tab characters are
 " needed, and have indentation at 8 chars to be sure that all indents are tabs
 autocmd FileType make set noexpandtab shiftwidth=8 softtabstop=0

Source:
https://superuser.com/questions/632657/how-to-setup-vim-to-edit-both-makefile-and-normal-code-files
https://github.com/spf13/spf13-vim/issues/789#issuecomment-118369177

Categories: vim Tags:

Clear highlighting on escape in normal mode

December 22, 2016 Leave a comment

Problem:
How to disable highlighted text after doing a search in vim?

Solution:
Added the following to my .vimrc

 " Clear highlighting on escape in normal mode
 nnoremap <esc> :nohlsearch<return><esc>
 nnoremap <esc>^[ <esc>^[

System details:
vagrant box running ubuntu/trusty64

Source:
http://stackoverflow.com/questions/657447/vim-clear-last-search-highlighting?rq=1

Categories: vim Tags: ,

Custom Colors

December 21, 2016 Leave a comment

Problem:
I had set up my vim to run flake8 when I save python files. The issue now was that the quickfix window would display the errors in white/white-grey text on a yellow background. That proved to be really hard to read.

white on yellow

Solution:
1. One option was to change my colorscheme to something that would display the text. (Many hours later I still had not found a colorscheme that I liked.)
2. Change the color for just that “aspect”.

So I went with option 2 and changed the color. Which resulted in black on yellow and is now much easier to read.
screen-shot-2016-12-21-at-22-13-58

Steps:
While in vim look at the current colors that are already set. (:highlight or :hi)

:highlight

highlight

The colors I wanted to change were for ‘Search’. So while still in vim

:highlight Search term=reverse ctermbg=11 ctermfg=0  guibg=Yellow

To make this permanent I added the following to .vimrc

highlight clear
highlight Search term=reverse ctermbg=11 ctermfg=0  guibg=Yellow

Source:
http://andrewradev.com/2011/08/06/making-vim-pretty-with-custom-colors/
http://superuser.com/questions/654919/how-to-turn-off-gvim-error-highlighting

Categories: vim Tags: