vim

How do I fix vim to properly indent folds containing Python comment lines?

一曲冷凌霜 提交于 2019-12-22 03:25:29
问题 I set vim's foldmethod to indent which works very well when writing Python except when I have a comment line. For example, if I have this bit of code: def myFunction(): # here is my comment myString = "hello" myInt = 2 If I have my cursor on the comment line and type "za" I get get an error saying "E490: No fold found." If I have the cursor on the line beginning with "myString = " I will geta fold like this: def myFunction(): # here is my comment +--- 2 lines: myString = "hello" -------------

How to split text into multiple lines based on a pattern using Vim?

半城伤御伤魂 提交于 2019-12-22 03:24:14
问题 Suppose you have this text: name1 = "John"; age1 = 41; name2 = "Jane"; age2 = 32; name3 = "Mike"; age3 = 36; ... and you want to split each line into two lines to give a result like this: name1 = "John"; age1 = 41; name2 = "Jane"; age2 = 32; name3 = "Mike"; age3 = 36; ... How would you automate this operation? Some notes: I already tried the following method: (1) Select the text in virtual-vode, (2) Execute :'<,'>:norm ^3f r^M ***, but it doesn't work correctly; it splits only half of the

How do I join pairs of consecutive lines in a large file (1 million lines) using vim, sed, or another similar tool?

橙三吉。 提交于 2019-12-22 03:18:05
问题 I need to move the contents of every second line up to the line above such that line2's data is alongside line1's, either comma or space separated works. Input: line1 line2 line3 line4 Output: line1 line2 line3 line4 I've been doing it in vim with a simple recording but vim seems to crash when I tell it to do it 100 000 times... I'm thinking maybe sed would be a good alternative but not sure how to do what I want or maybe there's a better option? Each line only contains 1 numerical value, I

Vim and Ruby - matching “do”s and “end”s?

爱⌒轻易说出口 提交于 2019-12-22 02:22:40
问题 I'm sure we're all familiar with the "unexpected kEnd" problem. They are always (to me) a lot of trouble to track down, because Vim doesn't match "do"s and "end"s. (And, obviously, other elements that end with "end", like "if") Is there a way to configure Vim to show these matches to help make debugging easier? 回答1: If you are using a recent vim (I'm using 7.4), the built-in matchit macro works well with ruby code. Simply enable it by adding the following to your .vimrc runtime macros/matchit

Vim and Ruby - matching “do”s and “end”s?

為{幸葍}努か 提交于 2019-12-22 02:22:14
问题 I'm sure we're all familiar with the "unexpected kEnd" problem. They are always (to me) a lot of trouble to track down, because Vim doesn't match "do"s and "end"s. (And, obviously, other elements that end with "end", like "if") Is there a way to configure Vim to show these matches to help make debugging easier? 回答1: If you are using a recent vim (I'm using 7.4), the built-in matchit macro works well with ruby code. Simply enable it by adding the following to your .vimrc runtime macros/matchit

what's the fastest way to select a function of Python via VIM?

你。 提交于 2019-12-22 01:53:27
问题 Is it possible without any plugins? Or what's the best plugin for edit python file? 回答1: try vis to visualy select and o to jump edges 回答2: With this plugin https://github.com/bps/vim-textobj-python you can select, delete, change, etc: af: a function if: inner function ac: a class ic: inner class 回答3: The way I do it is not specific to functions. It will just select a continuous code of Python code: v]] if what you want to select is below the cursor v[[ if it is above the cursor. Just remove

terminal vim not loading .zshrc

谁说胖子不能爱 提交于 2019-12-22 01:52:00
问题 My terminal vim configuration is not loading the ~/.zshrc. Zsh is the environment login shell. What is the proper configuration for this situation? Here are some measures I've already taken and since removed: set shell=zsh (uses zsh as shell but doesn't source the rc) set shellcmdflag=-ci (all output suspended) cat ~/.zshenv $ source ~/.zshrc (many errors when opening vim) 回答1: From the manual: Commands are first read from /etc/zshenv; this cannot be overridden. [...] Commands are then read

Opening a directory in vim

会有一股神秘感。 提交于 2019-12-22 01:27:43
问题 I'm a mac user giving vim a serious try. Most of the GUI editors I'm used to allow me to open a directory as a "project" by executing a command like: edit ~/www/example.com/ The vim equivalent vim ~/www/example.com/ will show me a list of files in the directory, and I can open them. But it does not set vim's working directory to that path, I have to run :cd . to set the working directory. Is there some way, perhaps with a shell script, to open vim and have it's working directory set to a

How do I unset a variable in Vim?

五迷三道 提交于 2019-12-22 01:23:51
问题 I have a plugin that sets a global variable and checks it each time the plugin is loaded to avoid loading itself multiple times. I would like to allow reloading of the plugin (allow reloading of the plugin) without altering the plugin itself. The plugin simply checks to see that it's variable exists (i.e. exists('g:var_name') )—is there a way to unset said variable so that the exists() check returns false? p.s. I don't want to alter the plugin itself because I use pathogen with git submodules

Vim编辑器

半腔热情 提交于 2019-12-22 00:15:51
vim编辑器: Linux使用文本文件来保存配置;文本编辑器用来编辑纯ASCII文件 Linux下常见的文本编辑器emacs、vi、nano vi(Visual Interface) 全屏文本编辑,模式化的编辑器(在不同的模式间转换) vim(vi improved) vi的增强版 vim的配置文件: 全局配置文件:/etc/vimrc、/etc/virc 用户配置文件:~/.vimrc、~/.virc 文件默认不存在可以自己手动创建 使用vim打开文件: vim File      打开或新建文件,并将光标置于第一行首 vim +N File     打开文件,并将光标置于第N行首 vim + File      打开文件,并将光标置于最后一行首 vim +/Pattern File 打开文件,并将光标置于第一个与"Pattern"匹配的字符串处 vim -r File     在上次正用vim编辑时发生系统崩溃,恢复"File"  vim -b File     二进制方式打开文件  vim -d File1 File2…比较多个文件(如果有不同的话会做出标注) vim File1 File2…  打开多个文件,依次编辑 vim -m File     只读打开文件,只能查看文件不能修改 打开多文件时文件间跳转 :n或:next 编辑下一个文件 :N或:prev 编辑上一个文件