Top 10 Python libraries of 2016 — thoughts…
Last year, we did a recap with what we thought were the best Python libraries of 2015, which was widely shared within the Python community (see post in r/Python). A year has gone by, and again it is time to give due credit for the awesome work that has been done by the open source […]
Clear highlighting on escape in normal mode
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
Custom Colors
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.
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.
Steps:
While in vim look at the current colors that are already set. (:highlight or :hi)
: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
QuickFix
QuickFix is designed to display compiler errors — a list of errors is displayed and can be selected to jump to a specific file and line.
:cn — Go to the next location in the list
:cp — Go to the previous location
:ccl — Close the quickfix window
Depending on where your quickfix window is. You can use below keys to move in and out of the window. (If quickfix window is at the bottom part of your screen)
CTRL-w + j — Move into the quickfix window
CTRL-w + k — Move out of the quickfix window
The window commands will work here. See link in source section below for more details.
Source:
http://usevim.com/2012/08/24/vim101-quickfix/
http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix
http://vimdoc.sourceforge.net/htmldoc/windows.html#windows
pip – ValueError: (‘Expected version spec in’…
Problem:
I was not able to install a package from pip.
$ pip -V pip 1.5.4 from /home/vagrant/envs/projects/local/lib/python2.7/site-packages (python 2.7) $ less requirements.txt --extra-index-url http://repository.example.com:6543/pypi/ --trusted-host repository.example.com SQLAlchemy==1.1.4 flake8==3.2.1 mccabe==0.5.3 psycopg2==2.6.2 pyflakes==1.3.0 custom-application-from-repository==0.1.0 $ pip -r requirements.txt Exception: Traceback (most recent call last): File "/home/vagrant/envs/projects/local/lib/python2.7/site-packages/pip/basecommand.py", line 122, in main status = self.run(options, args) File "/home/vagrant/envs/projects/local/lib/python2.7/site-packages/pip/commands/install.py", line 262, in run for req in parse_requirements(filename, finder=finder, options=options, session=session): File "/home/vagrant/envs/projects/local/lib/python2.7/site-packages/pip/req.py", line 1631, in parse_requirements req = InstallRequirement.from_line(line, comes_from, prereleases=getattr(options, "pre", None)) File "/home/vagrant/envs/projects/local/lib/python2.7/site-packages/pip/req.py", line 172, in from_line return cls(req, comes_from, url=url, prereleases=prereleases) File "/home/vagrant/envs/projects/local/lib/python2.7/site-packages/pip/req.py", line 70, in __init__ req = pkg_resources.Requirement.parse(req) File "/home/vagrant/envs/projects/local/lib/python2.7/site-packages/pip/_vendor/pkg_resources.py", line 2606, in parse reqs = list(parse_requirements(s)) File "/home/vagrant/envs/projects/local/lib/python2.7/site-packages/pip/_vendor/pkg_resources.py", line 2544, in parse_requirements line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec") File "/home/vagrant/envs/projects/local/lib/python2.7/site-packages/pip/_vendor/pkg_resources.py", line 2512, in scan_list raise ValueError("Expected "+item_name+" in",line,"at",line[p:]) ValueError: ('Expected version spec in', '--trusted-host repository.example.com', 'at', ' repository.example.com') Storing debug log for failure in /home/vagrant/.pip/pip.log
Solution:
1. Upgrade pip. The version I was using does not accept the extra parameters specified in requirements.txt
$ pip -U install pip
2. Now run pip install command again.
Note:
1. Using a vagrant box running ubuntu trusty.
vim-bracketed-paste
Problem:
Auto indent in vim was killing me! Every time I wanted to copy and paste some code into vim, it would auto indent the already indented code. So things were looking messy. A fix was to do “:set paste” before pasting code. Adding “set paste” to my .vimrc did not help cause for some reason code was getting auto indented when I pasted, so I had to “set nopaste”, then “set paste” to get it to ignore indentation.
Installing vim-bracketed-paste worked for me.
From http://cirw.in/blog/bracketed-paste
vim-bracketed-paste
Vim also handles newlines specially. When I am manually typing out code, vim will add extra space characters each time I hit return so that the resulting indentation is correct. Unfortunately when pasting into vim these extra spaces end up making a mess because the content I’m pasting already includes the correct indentation.
The usual work around for this is to manually run “:set paste” inside vim before pasting, but I often forget. The vim-bracketed-paste plugin uses code from Chis Page to do this automatically for me, so the content I paste into vim does not get automatically indented but the lines I type manually still do. You can install this plugin using pathogen, or by copy-pasting the code into your ~/.vimrc.
dh-virtualenv
What is dh-virtualenv
dh-virtualenv is a tool that aims to combine Debian packaging with self-contained virtualenv based Python deployments.
Dillinger – online Markdown editor.
Dillinger is an online cloud-enabled, HTML5, buzzword-filled Markdown editor.
http://dillinger.io