Python Syntax Highlighting in Notepad++ - python

I know Notepad++ supports Python but under the language menu I cannot find it! At "P," it only lists
Pascal, Perl, PHP, Postscript, PowerShell, and strangely, Properties. I am writing some Python scripts and I want the
syntax to be highlighted. How can I activate Python highlighting?

Maybe it's disabled. Check in Preferences | Language Menu/Tab Settings if it's not among the disabled items.

Weird. I have Notepad++ v6.3 on this PC and it is there:

Try to uninstall and reinstall Notepad++. Be sure to get the latest version from SourceForge -
http://sourceforge.net/projects/notepad-plus/

Please make sure it is not disabled. I happens to me too.
To check go to preferences, click on language items in the left and make sure that python is not in disabled languages.
Reboot notepad++ after applying changes.

Try to uninstall and install the new version form Notepad++

On mine, notepad++ v7.5.8, Python is not in the P section but it is in the bottom of languages menu.
This is the default arrangement for my version of notepad++ so all bets are off if you changed it under settings.

Yes, python is at the bottom of language list (not under P item - I believe it was moved out of P after I played with Settings) .

Related

How can I get auto-indentation to work with Python 2.7 on Xcode 7.3?

I've used this guide to set up Xcode to build Python scripts. When I press return, the cursor always goes back to the beginning of the new line, even though automatic indenting based on syntax is turned on in the preferences menu. It's frustrating to have to press the space key eight times to get two blocks in indenting in every time. Is there something I haven't installed correctly? I have Anaconda installed and as my build tool if that helps.
I would suggest running Python on something else imho. Something like PyCharm or IPython. The problem with Xcode is that Python is not one of the native languages for it. So Xcode doesn't know the proper formatting for Pythons syntax.
Not to mention that debugging and other features might not work well on Xcode.

Using VIM for Python IDE in Windows?

I am turning to Python from .NET world. And Visual Studio was something a great tool i used.
In python world we do have basic IDLE and another one is VIM. I have seen that a lot of developers have configured VIM to a great IDE. Using basic VIM in Windows 7 seems of less use.
So i want to moderate my VIM to a level which has file explorer, syntax highlighting, search, error highlighting etc. So that it gives feel of Visual Studio and more productive.
But all hacks/tips available are for Linux/Ubuntu users mostly, which i may use later but as of now i need to make my VIM in Windows more productive, visual.
Please Suggest some Tips/Hacks/Resources to look around for VIM configuration?
Thanks
This question addresses your low level issue: coding Python with an IDE that is not VS.
There are a few popular blog posts addressing your high level issue: setting up Vim for Python development. They are a quick google away…
I feel the need to point out that Vim is not an IDE. You can customize it a lot and end up with something that looks like an IDE but you won't get an IDE. Only an over-customized text editor.
Anyway, here are a few tips for starting out with Vim:
Do $ vimtutor as many times as needed to feel comfortable with the basics.
Get familiar with Vim's buit-in documentation: the answers to most of your questions are somewhere inside. :help gets you to the front page, :help 'option' shows the documentation for option, :help :command shows the documentation for command… Hit <C-]> on a colored word to jump to its definition.
Don't use Janus or SPF13 or whatever pre-packaged set of plugins. You'll only grow bad habits. Similarly, don't copy other people's vimrc wholesale.
Ctags is an external code indexer that is used by Vim to "jump to definition" with <C-]>. cscope is another option, it's more powerful but also a little more complex. See :help tags.
Related to ctags, TagList and TagBar are two popular plugins used to display more or less the equivalent of the Object Browser in VS.
NERDTree is another popular plugin that mimicks the file tree found in many IDEs/editors. But Vim comes with netrw (:Ex) by default, try it before installing NERDTree.
Read :help motion.txt as soon as possible.
Watch Drew Neil's laser-guided vimcasts.
Don't rush it.
you can use vim plugins on windows, http://www.vim.org/scripts/index.php, typing "vim {your feature here}" into google will come up with lots of results.
popular file explorer is nerdtree,
syntax highlighting can be turned on with
syntax on in your vimrc
searching open file is easy to do using reg exes . Initialize search with /.
Searching directory is easy to do using grep.
I don't develop on windows but i have read that Cygwin might be worth installing for some linux tools if not already installed.
I am in no way an evangelist of any Editor/IDE.
But, if you are a newbie to Python I would suggest trying out Sublime Text 2 http://www.sublimetext.com/ . It is a very light weight yet powerful editor with a great following and it has a free evaluation version with no deadline.
But, if you intend to work using frameworks such as Django/ GAE then I would suggest using PyCharm from JetBrains
http://www.jetbrains.com/pycharm/
Finally, these tools are all just personal choices until you get comfortable with one or two of them.
Thanks,
-Hari
One possible compromise is to use your favorite IDE with a vim emulator plugin. For example, in Eclipse you can use Vrapper, PyCharm has IdeaVim and so forth. Lighttable also has vim key-bindings. The plug-ins (or key-binding options) give you some of the benefits of editing in Vim while still having the powerful debugging / navigation features, etc. of a full-blown IDE. BTW, Vrapper works with PyDev.
Using an emulator in an IDE allows you to gain the "muscle-memory" necessary for effective vim editing, without getting bogged down in "configuration hell" associated with turning an editor into an IDE (which auto-complete plugin do I use?..etc.?). Once you have mastered the vim keystrokes for normal and visual mode, used along with insert mode, you may decide to continue on into pure Vim and face those issues.
I wouldn't recommend to learn VIM in 2012 (despite it being a great editor). If you must, this blog post will get you started.
But VIM isn't an IDE, it's a text editor.
If you really want a powerful IDE, try IntelliJ IDEA or Eclipse. Both have great plugins to turn them into Python IDEs (along with code completion and all the other nice time savers). For Eclipse, try PyDev. For IntelliJ, search for Python in the plugin preferences pages.

Vim autocomplete for Python

I am trying to incorporate an autocomplete feature in Vim. I have used the omnicompletion of Vim as well as Pydiction. But in both the cases this message pops up:
Omni completion (^O^N^P) Pattern not found
I have tried Vim's Omnicompletion with Python just doesn't work. But this is not helping. Is there a workaround?
Try Jedi! There's a Vim plugin at https://github.com/davidhalter/jedi-vim.
It works just much better than anything else for Python in Vim. It even has support for renaming, goto, etc. The best part is probably that it really tries to understand your code (decorators, generators, etc. Just look at the feature list).
As pointed out by in the comments, this answers is outdated. youcompleteme now supports python3 and jedi-vim no longer breaks the undo history.
Original answer below.
AFAIK there are three options, each with its disadvantages:
youcompleteme: unfriendly to install, but works nice if you manage to get it working. However python3 is not supported.
jedi-vim: coolest name, but breaks your undo history.
python-mode does a lot more the autocomplete: folding, syntax checking, highlighting. Personally I prefer scripts that do 1 thing well, as they are easier to manage (and replace). Differently from the two other options, it uses rope instead of jedi for autocompletion.
Python 3 and undo history (gundo!) are a must for me, so options 1 and 2 are out.
This can be a good option if you want python completion as well as other languages. https://github.com/Valloric/YouCompleteMe
The python completion is jedi based same as jedi-vim.
I tried pydiction (didn't work for me) and the normal omnicompletion (too limited). I looked into Jedi as suggested but found it too complex to set up. I found python-mode, which in the end satisfied my needs. Thanks #klen.
I found a good choice to be coc.nvim with the python language server.
It takes a bit of effort to set up. I got frustrated with jedi-vim, because it would always freeze vim for a bit when completing. coc.nvim doesn't do it because it's asyncronous, meaning that . It also gives you linting for your code. It supports many other languages and is highly configurable.
The python language server uses jedi so you get the same completion as you would get from jedi.
Use install coc.nvim package and CocInstall coc-pyright
if you are using vim-plug:
Plug 'neoclide/coc.nvim'
:PlugInstall
CocInstall coc-pyright
I ran into this on my Mac using the MacPorts vim with +python. Problem was that the MacPorts vim will only bind to python 2.5 with +python, while my extensions were installed under python 2.7. Installing the extensions using pip-2.5 solved it.

Notepad++ indentation messes up

I'm coding in Python and I really like Notepad++. However, off late when I use tab to indent, it seems fine in Notepad++, but when I run the program I get an indentation error, and when I check my code in Emacs or something, I find that Notepad++ actually adds more tab spaces than it shows on screen. What is happening?
There is no universal tab size, so I always make sure to replace tabs by spaces (so you know what you see is what you get everywhere else as well)
Go to Settings -> "Preferences..." -> Language Menu/Tab Settings and check 'Replace by space'
I would suggest going to View > Show Symbol > Show Whitespace and Tab to get an better idea of how your indentations look.
PEP 8 tells us to use spaces instead of tabs in Python for cross-editor compatibility and consistency:
http://www.python.org/dev/peps/pep-0008/
Have a look at this answer for how to change tabs to spaces in Notepad++
Convert tabs to spaces in Notepad++
Perhaps that will fix your problem
Tiny update - to get spaces as tabs, you now go to Settings>>Preferences>>Tab Settings and check the "Replace by space" box
I am new to python and started using Notepad++. But I faced the same issue as you... Indentation problems. On my senior's advice, I switched to PyCharm community edition. I pasted the code from Notepad++ to PyCharm and it highlighted the block with indentation problems... The issue was that, some of the lines used spaces and some used tabs. This happened because the code on which I was working was taken from the internet.
Checking for such inconsistencies would solve the problem. Or, there is a better alternative... Switch to PyCharm. It is exclusively built for python coding.. Hope this helps people like me searching for solutions for indentation issues in Notepad++
Use Python Indent Plugin for Notepad++:
I have used both Pycharm & Notepad++, and frankly - even though both are installed on my machine right now I prefer using Notepad++. So, if you want to continue using Notepad++ for Python development you should definitely install the 'Python Indent' Plugin. This plugin will automatically create tabs for you when writing Python code. The only downside to the plugin is you have to remember to Enable it (by going to Plugins --> Python Indent and then clicking 'Enable') when you want to use it.
To install the Python Indent plugin in Notepad++ just go to 'Plugins' --> 'Plugin Manager' and then click on 'Show Plugin Manager'. Then check off 'Python Indent' and click on the 'Install' button.
Additionally, you should Follow Python's Usage Guide:
Tab spacing can differ across programs and, following the recommendations of PEP8 (Python Enhancement Proposals Number 8 - which is Python's Accepted Styling and Usage Guide) you should use the space bar to make your indents. Check out the PEP8 Page about spacing here: https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces
Good luck!

New to Python. Need info on the environment for it

I'm a complete newbie to Python. I've worked on PHP/JavaScript earlier but starting today I'm moving onto Python. I have no idea about the environment needed for it. I could use some suggestions on it for me to get started.
Under Unix, Emacs is a good choice, to which I always come back, because it is convenient to have a single editor for everything, and because it's open source.
What is best for you depends on your past experience with IDEs. I'd say: stick with what you've been using, or take this opportunity to try an even better IDE.
Note: Python comes with Idle, which is a very simple (if limited) IDE.
Be sure to check out IPython. It's an enhanced interactive python shell with a bunch of useful features such as Tab-Completion using introspection (eg, type "my_object." to see a list of its attributes and methods), logging your interactive session to an executable python-file, defining macros, etc. The documentation page has a link to the tutorial as well as screencasts showing it in action.
On my mac/Linux machines, python came pre-installed. On windows I use both jython under the eclipse IDE and ActivePython with their IDE/eclipse.   With eclipse you'll want PyDev.
It all depends on what you are looking for and what you are already using.
For instance, if you are using a more 'simple' editor at the moment: as long as it's got Python syntax you've got the basics.
If you are used to e.g. Eclipse you can just continue to use that, combined with Pydev. Besides syntax highlighting you'll also get more fancy features to help you debug and refactor your code.
Personally I use Emacs with python-mode (and a few other modes to interface with Subversion and Git). In the past I used Vim which also worked quite well.
My advice would be to start out with your current environment as long as it has some rudimentary support for Python. Once you are familiar with the language, start exploring what your environment is missing and either add it or if you cannot, switch to an enviroment which does support the feature.
I use gvim with some plugin in order to have better support for python.
If you like IDE, look at wing IDE wich is the best I have tested so far. Especially the debuger included is really helpful.
The Python Beginner's Guide and the official Python Tutorial both seem like good places to start.
Geany is a good option for a Linux setup, it's intellisense isn't that great but syntax highlighting is good and it can compile your code directly from inside the editor, plus it handles other languages such as C/C++, PHP, Java etc... Eric is another popular choice as it's a full IDE and I know some people use Eclipse.
On windows I use Notepad++, but it's mostly because I like text editors instead of fully blown IDE's.
Reference wise Daniel's choices are very good places to start, also check out Green Tea Press who do free computer books, there are two Python choices on there but the "Python for Software Design" book hasn't yet been published properly although you can download the manuscript. The "How to Think Like a Computer Scientist" book is a good one and not as scary as it sounds.
IDLE is nice to try out things. Other tools that people like are Eclipse with the Pydev plugin which seems to work ok, although it has crashed a few times (Eclipse, that is) and NetBeans (which I haven't tried) but some people seem to like.
I can only help you if you're running a Mac. Download Xcode. I believe that Python 2.3 comes bundled with these development tools. Luckily enough, this is all you really need to get started, unless you want a newer version of Python.
All you need to do is open up Terminal and type python. You're done!

Categories

Resources